{"id":9336,"date":"2023-01-27T10:33:39","date_gmt":"2023-01-27T15:33:39","guid":{"rendered":"https:\/\/blogs.mathworks.com\/student-lounge\/?p=9336"},"modified":"2025-02-21T10:00:58","modified_gmt":"2025-02-21T15:00:58","slug":"youve-got-to-be-modeling-me","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/student-lounge\/2023\/01\/27\/youve-got-to-be-modeling-me\/","title":{"rendered":"You\u2019ve Got to be Modeling Me"},"content":{"rendered":"<div class=\"rtcContent\">\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-style: italic;\">Joining us today is Wesley Hamilton, who is a STEM Outreach Engineer here at MathWorks. Wesley will talk about tackling the 2019 MathWorks Math Modeling Challenge (M3C) problem. <\/span><span style=\"font-style: italic;\">Wesley, over to you&#8230; <\/span><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\n<h2 id=\"H_28565511\" style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Introduction<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Hello all, I&#8217;m Wesley and in this blog post we&#8217;ll start tackling the <a href=\"https:\/\/m3challenge.siam.org\/archives\/2019\/problem\">2019 MathWorks Math Modeling Challenge (M3C) problem<\/a>. The M3C is a free, annual math modeling competition for high school (HS) juniors and seniors in the U.S. and sixth form students in England and Wales, and is a program of the Society of Industrial and Applied Math. More information about the M3C can be found on their <a href=\"http:\/\/m3challenge.siam.org\">website<\/a>, including two <a href=\"https:\/\/m3challenge.siam.org\/resources\/modeling-handbook\">free workbooks<\/a> aimed at preparing participants and their coaches to take part in the M3C!<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Here we&#8217;ll tackle the 2019 M3C problem by building an initial model for the first part of the challenge. To do this we will make use of best modeling practices, including identifying variables and making assumptions, as well as use MATLAB\u2019s data analysis and curve fitting toolboxes to support our modeling process. Note that this approach isn\u2019t the only way teams might approach this problem (though some of the top submissions did something similar!); our goal is to see what <span style=\"font-style: italic;\">a<\/span> start might look like.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">M3C problems consist of three parts. The first part is designed to be doable by most, if not all, teams. The next two parts typically build on work from the first part, but feature more open-ended questions that let teams showcase their creativity and technical prowess when developing models and solutions to the stated questions. As I mentioned, we\u2019ll focus in on part 1 of the 2019 M3C problem and set ourselves up with a solid start for tackling the rest of the challenge.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The general outline we&#8217;ll follow is<\/div>\n<ol style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">read the problem in its entirety,<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">formulate a plan to answer the problem,<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">carry out our plan.<\/li>\n<\/ol>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Throughout this process we&#8217;ll make use of MATLAB, a scientific and engineering programming language developed by MathWorks. If you&#8217;re new to MATLAB (or programming), MathWorks has a <a href=\"https:\/\/matlabacademy.mathworks.com\/details\/matlab-onramp\/gettingstarted\">free OnRamp<\/a> to help you get started. Teams taking part in the M3C can request <a href=\"https:\/\/www.mathworks.com\/academia\/student-competitions\/mathworks-math-modeling-challenge.html\">complimentary MATLAB<\/a> licenses for the competition. Some of these resources (and much more!) can be found on the <a href=\"https:\/\/m3challenge.siam.org\/resources\/learn-technical-computing\">M3C&#8217;s &#8220;Learn Technical Computing&#8221; website<\/a>.<\/div>\n<div style=\"margin-bottom: 20px; padding-bottom: 4px;\">\n<div style=\"margin: 0px; padding: 10px 0px 10px 5px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: bold; text-align: start;\"><span style=\"font-weight: bold;\">Table of Contents<\/span><\/div>\n<div style=\"margin: -1px 0px 0px; padding: 10px 0px 10px 7px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: start;\"><a href=\"#H_28565511\">Introduction<br \/>\n<\/a><a href=\"#H_D2397CF2\">Initial reading of the problem<br \/>\n<\/a><a href=\"#H_79472D09\">Examining the attachments and data<br \/>\n<\/a><a href=\"#H_2EA96675\">Initial plan for model<br \/>\n<\/a><a href=\"#H_32DE576F\">Reading in and processing the data<br \/>\n<\/a><a href=\"#H_D5E54115\">Quick Live Script housekeeping<br \/>\n<\/a><a href=\"#H_DA9C85CB\">Building a model by fitting a curve<br \/>\n<\/a><a href=\"#H_B1B802F6\">Comparing to historical data<br \/>\n<\/a><a href=\"#H_E48C31F5\">Summary of progress and next steps<\/a><\/div>\n<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\n<h2 id=\"H_D2397CF2\" style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Initial reading of the problem<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Let\u2019s start by reading the <a href=\"https:\/\/m3challenge.siam.org\/archives\/2019\/problem\">part 1 problem statement<\/a> in its entirety (in the actual competition we&#8217;d read the entire problem). In addition to setting the stage for why someone might want to know the answer to these questions, the introduction often contains pieces of information that will be helpful to us as we answer the questions.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">We\u2019ll start by reading the introduction for context of the problem:<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-style: italic;\">Substances such as tobacco, alcohol, and narcotics can affect the physical and mental health of users. The consequences of substance abuse, both financial (health care, the criminal justice system, workplace productivity, etc) and non-financial (divorce, domestic abuse, etc), ripple through society and affect more than just the user. The effects of substance abuse on individuals and society have come to the forefront recently as opioid addiction has become prominent [<\/span><a href=\"https:\/\/m3challenge.siam.org\/archives\/2019\/problem#1\"><span style=\"font-style: italic; text-decoration: underline;\">1<\/span><\/a><span style=\"font-style: italic;\">].<\/span><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">We see they provide a reference to an NPR article on Opioid overdoses in the United States. Let\u2019s hold off on looking at the article until we finish reading the problem statement:<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-style: italic;\">Efforts, such as taxes and regulations on cigarettes and the Drug Abuse Resistance Education program, have been made at the local, state, and national level to educate, control, and\/or restrict the consumption of such substances. Such efforts need to start with an understanding of how substance abuse spreads and affects some individuals more than others.<\/span><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now to part 1, what we are actually being asked to do:<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-weight: bold; font-style: italic;\">Darth Vapor<\/span><span style=\"font-style: italic;\">\u2014Often containing high doses of nicotine, vaping (inhalation of an aerosol created by vaporizing a liquid) is hooking a new generation that might otherwise have chosen not to use tobacco products. Build a mathematical model that predicts the spread of nicotine use due to vaping over the next 10 years. Analyze how the growth of this new form of nicotine use compares to that of cigarettes.<\/span><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The last two sentences are key, and worth repeating: &#8220;<span style=\"font-weight: bold;\">Build a mathematical model<\/span> that predicts the spread of nicotine use due to vaping over the next 10 years. <span style=\"font-weight: bold;\">Analyze how the growth<\/span> of this new form of nicotine use compares to that of cigarettes.\u201d<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">So, our task is to model the spread of nicotine use due to vaping and compare our model to the usage of cigarettes. Some questions I already have in mind are: how do we measure the spread or use? Do we keep track of vape usage by the number of cartridges used? By number of users?<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">If you don\u2019t know how vaping works, this would be an opportunity to perform some research to inform some of the questions we\u2019re coming up with. Let\u2019s open a new <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/matlab_prog\/what-is-a-live-script-or-function.html\">MATLAB Live Script<\/a> to start taking notes, starting with the tasks of part 1; let\u2019s convert this to \u201ctext\u201d, and then copy over the two key sentences.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 832px; height: 468px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_1.gif\" alt=\"view_1.gif\" width=\"832\" height=\"468\" \/><\/div>\n<h2 id=\"H_79472D09\" style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Examining the attachments and data<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now let\u2019s look at the <a href=\"https:\/\/m3challenge.siam.org\/resources\/archives\/2019-year-at-a-glance\/2019-problem-one-is-too-many-and-a-thousand-not-enough-substance-use-and-abuse\/\">provided data<\/a>. Let\u2019s start with the Figure on historical cigarette usage. \u201cAdult* per capita cigarette consumption and major smoking and health events, United States, 1900\u20132012.\u201d<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 779px; height: 568px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_2.png\" alt=\"view_figure.png\" width=\"779\" height=\"568\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The first thing we should take note of as we look at this graph is the labels on the axes. The x-axis has time in years, and the y-axis is labeled \u201cper capita number of cigarettes smoked per year\u201d. If you\u2019re not sure what per capita means, you should take a moment to do a search for that term so you can fully understand the meaning of the data you have. A quick search turns up that the phrase per capita is often used to replace the words \u201cper person\u201d. So, this data gives us the average number of cigarettes consumed per person each year. This data does not tell us what percentage of the population smokes. However, we can make an assumption that if we did have that data, it might \u201clook\u201d similar to this data in terms of shape. Let\u2019s capture that assumption in our Live Script. If we have time later on, we might search for data to support this assumption.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 832px; height: 468px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_3.gif\" alt=\"view_3.gif\" width=\"832\" height=\"468\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Speaking of shape, next we might examine the shape of the curve. It starts near zero on the y-axis, hits a peak in the 1960s and 1970s, and then decreases. The shape of this curve reminds me of a Bell curve, or Normal distribution, also called a Gaussian, from probability theory.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now let&#8217;s take a look at the provided data, starting with the \u201chigh_school_vaping_data.xlsx\u201d data. The title of the actual spreadsheet is \u201cPercentage of High School Students who used e-cigarettes in the past 30 days, by gender and race\/ethnicity; National Youth Tobacco Survey, 2011-2015\u201d.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 780px; height: 439px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_4.png\" alt=\"hs_vaping_data_spreadsheet.png\" width=\"780\" height=\"439\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">This data looks to be for <span style=\"font-style: italic;\">all<\/span> HS students (9th through 12th grade), and splits it up based on gender and race\/ethnicity. Already it looks like we\u2019ll need to do a little pre-processing if we want to read in the data, because it includes the percentage along with a confidence interval in parentheses in each cell (think of a confidence interval as the error bounds coming from the survey sampling); for MATLAB to happily read it in, there should be a single number in each cell. We also don\u2019t know (without extra research) what percentage of HS students are White or Hispanic\/Latino, so we might have to put in extra work if we want to mix and match the data objects that aren\u2019t in the \u201cOverall\u201d row.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Finally, let\u2019s look at the \u201cNIH-DrugTrends-DataSheet.xlsx\u201d.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 780px; height: 439px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_5.png\" alt=\"hs_drug_data_spreadsheet.png\" width=\"780\" height=\"439\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">This contains a lot more data on various drugs, but especially relevant for us we see the row corresponding to \u201cany vaping in the past month\u201d. This data is for the years 2015 to 2018, and is split amongst 8th grade, 10th grade, and 12th grade. Also, because of how the data is formatted, we\u2019ll have to perform a little pre-processing before we can read it into MATLAB (like the other spreadsheet). Since the other data is for the years 2011 &#8211; 2015, we might want to merge the two datasets so we have data for HS vape usage from 2011 &#8211; 2018, which gives our model more to work with. We can justify this by making an assumption that &#8220;the National Youth Tobacco Survey and NIH Drug Trends data are comparable&#8221;. We&#8217;ll have to decide which dataset we use for the 2015 data, but we can do that after we&#8217;ve read the data in and are starting to build the model.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 832px; height: 468px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_6.gif\" alt=\"view_3.gif\" width=\"832\" height=\"468\" \/><\/div>\n<h2 id=\"H_2EA96675\" style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Initial plan for model<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now that we\u2019ve taken a look at the provided data, let\u2019s formulate an initial plan of attack to get started with a solution. For assumptions so far we have:<\/div>\n<ul style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">cigarette per capita usage is comparable to number of people smoking (so that when we go to compare e-cigarette usage with cigarette usage, we can tie in that figure of historical cigarette usage), and<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">the National Youth Tobacco Survey and NIH Drug Trends data are comparable (so that we can combine the two datasets so we have more data to work with).<\/li>\n<\/ul>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">For a course of action, let\u2019s:<\/div>\n<ol style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Pre-process the data and read it in.<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Try to fit some curves to the data to predict usage in the future. We might hope that fitting a Gaussian to the data works best, so that we have some basis to say that e-cigarette usage will mimic historical cigarette trends, but let\u2019s see how the models behave first.<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Write a short summary, which we could then copy and paste into our final report.<\/li>\n<\/ol>\n<h2 id=\"H_32DE576F\" style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Reading in and processing the data<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now let\u2019s preprocess the data. Since the spreadsheet has the percentages with confidence intervals in the same cells, it&#8217;s easiest if we manually re-enter the data into a different sheet. This will make importing the data significantly easier later on. I&#8217;ve also incorporated the confidence intervals by including the low (lower bound of the interval), medium (reported survey result), and high (upper bound of the interval) estimates in the spreadsheet.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 780px; height: 439px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_7.png\" alt=\"hs_vaping_data_preprocessed.png\" width=\"780\" height=\"439\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Next, let&#8217;s do the same thing with the 10th and 12th grade data from the NIH data. Since we want to compare vaping to cigarette usage, let\u2019s record both the e-cigarette and cigarette data. In this case, let\u2019s actually use the \u201cAny vaping\u201d in the \u201cpast month\u201d data, where we\u2019re assuming vaping and e-cigarette usage are comparable data. Otherwise we\u2019re going to do the same thing as before: copy the values into a new spreadsheet page so they\u2019re easy to read in.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 780px; height: 438px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_8.png\" alt=\"hs_drug_data_preprocessed.png\" width=\"780\" height=\"438\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">With the data ready, let\u2019s use MATLAB to import everything we&#8217;ll be using. For this, we\u2019re going to use the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/importtool.html\">\u201cImport Data\u201d app<\/a> on the home bar, as demonstrated below. For now we&#8217;ll just plan to use the &#8220;med&#8221; values and save the confidence intervals (&#8220;low&#8221; and &#8220;high&#8221; values) for later, after we&#8217;ve made a solid start and looked at later parts of the challenge.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 832px; height: 468px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_9.gif\" alt=\"view_4.gif\" width=\"832\" height=\"468\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">To summarize the steps, we:<\/div>\n<ol style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">opened the &#8220;Import Data&#8221; app from the Home toolbar,<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">selected the spreadsheet \u201chigh_school_vaping_data.xlsx\u201d which has the data we want to import,<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">selected Sheet 2 of the spreadsheet, and selected the row of data we want to start with (since it\u2019s only one row, let\u2019s not bother with importing the column labels, and since we don&#8217;t need to worry about row labels, we&#8217;ll just import the numeric data),<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">clicked the &#8220;Import Selection&#8221; dropdown menu and selected &#8220;Generate Script&#8221; (so that we can easily modify the code later and not have to go through the app each time),<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">changed the name of the table that is imported into MATLAB, converted it to an array, and then ran the code to verify we imported the data correctly.<\/li>\n<\/ol>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Since we didn&#8217;t include a semicolon after &#8220;HSData = table2array(HSTable)&#8221;, MATLAB prints the result of that line of code, which shows us the contents of the array &#8220;HSData&#8221;, the data we expected to read in.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now let\u2019s repeat the same process with the NIH data. Here, we\u2019re recording 10th and 12th grader data for vaping and cigarette usage. As before, we select the correct spreadsheet, go to sheet 2, select the data (ignoring the data labels), and click \u201cimport selection\u201d and then \u201cgenerate script\u201d. As before, let\u2019s convert this data to an array, this time called &#8220;NIHData&#8221;.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 832px; height: 468px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_10.gif\" alt=\"view_5.gif\" width=\"832\" height=\"468\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Note that we also changed the view style for the Live Script, so that the output of code appears inline and not to the side of the editor. Also, since we&#8217;ve copied what we needed from the untitled.m files we can go ahead and close those tabs.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">One point worth mentioning here: this is a relatively small dataset, and we could have possibly analyzed the data in excel directly, and\/or manually type the data into MATLAB. The Import Data app is incredibly powerful when you start dealing with much larger datasets though, especially if you want to keep track of column or row labels, and is worth knowing about and getting comfortable with.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Once all of that is done, we can get started on our model! The code we generated is included here for reference (make sure the excel spreadsheets are located in the same folder as this Live Script):<\/div>\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 1px solid #bfbfbf; border-bottom: 0px none #212121; border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">%% Set up the Import Options and import the data<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts = spreadsheetImportOptions(<span style=\"color: #a709f5;\">&#8220;NumVariables&#8221;<\/span>, 6);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Specify sheet and range<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.Sheet = <span style=\"color: #a709f5;\">&#8220;Sheet2&#8221;<\/span>;<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.DataRange = <span style=\"color: #a709f5;\">&#8220;A3:F3&#8221;<\/span>;<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Specify column names and types<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.VariableNames = [<span style=\"color: #a709f5;\">&#8220;Var1&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName2&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName3&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName4&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName5&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName6&#8221;<\/span>];<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.SelectedVariableNames = [<span style=\"color: #a709f5;\">&#8220;VarName2&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName3&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName4&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName5&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName6&#8221;<\/span>];<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.VariableTypes = [<span style=\"color: #a709f5;\">&#8220;char&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;double&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;double&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;double&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;double&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;double&#8221;<\/span>];<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Specify variable properties<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts = setvaropts(opts, <span style=\"color: #a709f5;\">&#8220;Var1&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;WhitespaceRule&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;preserve&#8221;<\/span>);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts = setvaropts(opts, <span style=\"color: #a709f5;\">&#8220;Var1&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;EmptyFieldRule&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;auto&#8221;<\/span>);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Import the data<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">HSTable = readtable(<span style=\"color: #a709f5;\">&#8220;high_school_vaping_data.xlsx&#8221;<\/span>, opts, <span style=\"color: #a709f5;\">&#8220;UseExcel&#8221;<\/span>, false);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">HSData = table2array(HSTable)<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">%% Clear temporary variables<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">clear <span style=\"color: #a709f5;\">opts<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">%% Set up the Import Options and import the data<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts = spreadsheetImportOptions(<span style=\"color: #a709f5;\">&#8220;NumVariables&#8221;<\/span>, 5);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Specify sheet and range<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.Sheet = <span style=\"color: #a709f5;\">&#8220;Sheet2&#8221;<\/span>;<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.DataRange = <span style=\"color: #a709f5;\">&#8220;A2:E5&#8221;<\/span>;<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Specify column names and types<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.VariableNames = [<span style=\"color: #a709f5;\">&#8220;Var1&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName2&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName3&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName4&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName5&#8221;<\/span>];<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.SelectedVariableNames = [<span style=\"color: #a709f5;\">&#8220;VarName2&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName3&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName4&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;VarName5&#8221;<\/span>];<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.VariableTypes = [<span style=\"color: #a709f5;\">&#8220;char&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;double&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;double&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;double&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;double&#8221;<\/span>];<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Specify variable properties<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts = setvaropts(opts, <span style=\"color: #a709f5;\">&#8220;Var1&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;WhitespaceRule&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;preserve&#8221;<\/span>);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts = setvaropts(opts, <span style=\"color: #a709f5;\">&#8220;Var1&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;EmptyFieldRule&#8221;<\/span>, <span style=\"color: #a709f5;\">&#8220;auto&#8221;<\/span>);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Import the data<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">NIHTable = readtable(<span style=\"color: #a709f5;\">&#8220;NIH-DrugTrends-DataSheet .xlsx&#8221;<\/span>, opts, <span style=\"color: #a709f5;\">&#8220;UseExcel&#8221;<\/span>, false);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">NIHData = table2array(NIHTable)<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">%% Clear temporary variables<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 1px solid #bfbfbf; border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">clear <span style=\"color: #a709f5;\">opts<\/span><\/span><\/div>\n<\/div>\n<\/div>\n<h2 id=\"H_D5E54115\" style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Quick Live Script housekeeping<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now that our Live Script is growing, let&#8217;s add in a few section breaks and headers so it&#8217;s easier for us to revisit and use our code. Based on our strategy for tackling this problem, our sections will be:<\/div>\n<ol style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Report (where we write our assumptions and conclusions),<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Reading in data<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Vape model (where we predict future vape usage),<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Comparison to cigarettes.<\/li>\n<\/ol>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 832px; height: 468px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_11.gif\" alt=\"view_6.gif\" width=\"832\" height=\"468\" \/><\/div>\n<h2 id=\"H_DA9C85CB\" style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Building a model by fitting a curve<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Our plan here will be to model vape usage by fitting a curve to the data we\u2019ve imported, and use the fitted curve to say something about future vape usage. Two considerations arise:<\/div>\n<ul style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">The NIH data is split between 10th and 12th grade students. How do we use this data to say something about high school students as a whole?<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">We have 2 datasets (the high school vaping data and the NIH data) that cover the years 2011 to 2015, and 2015 to 2018. Can we combine the data in some way to have more data points with which to build the model?<\/li>\n<\/ul>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">For the first consideration, let\u2019s start by averaging the 10th and 12th grade data from the NIH for each year, and use that as an approximation for all of high school. Implicitly we\u2019re assuming that there are approximately the same number of 10th and 12th grade students in the study (so we can average the percentages) and that 10th and 12th grade students provide a reasonable approximation of how all high school students would behave; let&#8217;s actually add this assumption to our running list of assumptions, just in case (we may also want to break it up into two assumptions, but we can decide that later).<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 832px; height: 468px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_12.gif\" alt=\"view_11.gif\" width=\"832\" height=\"468\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">We\u2019ll use <a href=\"https:\/\/www.mathworks.com\/help\/fixedpoint\/ref\/mean.html\">MATLAB\u2019s mean function<\/a> to quickly average the percentages by columns, which correspond to years, of the first two rows of NIHdata.<\/div>\n<div class=\"preformatted-matlab\" style=\"margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;\">\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">NIHHSData = mean(NIHData(1:2,:))<\/span><\/div>\n<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">For the second consideration, we\u2019re going to take the HS data from 2011 to 2014, and use the NIHdata from 2015 to 2018. Here we\u2019re assuming that the methods of surveying are comparable for the two datasets, so it makes sense to merge them. Without looking into the studies themselves, one justification for this we can provide is that the NIH data 2015 value we have (15.25) is within the confidence interval for the HS vaping data (14.1 \u2013 18).<\/div>\n<div class=\"preformatted-matlab\" style=\"margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;\">\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">mergedData = [HSData(1:end-1), NIHHSData]<\/span><\/div>\n<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">This is a quick and handy trick for combining arrays into new ones, which is something you pick up the more you use MATLAB. More info about working with arrays can be found in <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/math\/creating-and-concatenating-matrices.html\">MathWorks&#8217; Help Center<\/a>. As a sanity check, let&#8217;s plot the data we&#8217;ve imported using the following code:<\/div>\n<div class=\"preformatted-matlab\" style=\"margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;\">\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% visualize the imported data<\/span><\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">years = 2011:2018;<\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">plot(years,mergedData)<\/span><\/div>\n<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Our Live Script should show us a plot of vape usage per year, as demonstrated below. In particular, vape usage seems to be on the rise.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 832px; height: 468px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_13.gif\" alt=\"view_7.gif\" width=\"832\" height=\"468\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now that we\u2019ve preprocessed and verified our data, let\u2019s use the built-in <a href=\"https:\/\/www.mathworks.com\/help\/curvefit\/getting-started-with-curve-fitting-toolbox.html\">&#8220;Curve Fitter&#8221; app<\/a>. Once the app opens we need to specify what data we want to fit a curve to by clicking the \u201cSelect Data\u201d button. We want \u201cyears\u201d as the X data and \u201cmergedData\u201d as Y data. The app automatically tries to fit a 1st degree polynomial (line) to the data, and we can play around with some options to see how 2nd and 3rd degree polynomials approximate the data as well.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 832px; height: 468px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_14.gif\" alt=\"view_8.gif\" width=\"832\" height=\"468\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">As soon as we specify the data to be used, we see the data plotted with a line (1-dimensional polynomial, behind the data selector window) automatically plotted. Is a line a reasonable model for vape usage? Well, it seems to \u201cfit\u201d the data well enough, but what happens as time increases? Since we\u2019re modeling the percentage of HS students vaping, as time increases our model tells us that near 2045, 100% of HS students will be vaping, near 2050 approximately 114% of HS students will be vaping, and so on. This doesn\u2019t make sense for our problem, and using 2nd and 3rd degree polynomials don&#8217;t seem to do any better: using a polynomial fit doesn\u2019t seem like the right way to go.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">If we think back to our earlier reading of the problem, the historical cigarette usage data looked like a Gaussian. Luckily, Gaussians are a built-in option in the curve fitting app, so let\u2019s try that next.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 780px; height: 534px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_15.png\" alt=\"view_10.png\" width=\"780\" height=\"534\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">If we click \u201cGaussian\u201d in the \u201cFit Type\u201d menu, our model is automatically generated and looks reasonable! From the plot we see that HS vape usage will peak near 2023 at 30%, and then tend towards 0% usage by around 2040. We\u2019re happy with this for now, so let\u2019s export the code to generate the fitted Gaussian and plot and copy it into our notebook. To do this, we want to click the \u201cExport Button\u201d and then \u201cGenerate Code\u201d. We can ignore the first few lines and just copy everything underneath \u201c%%Fit: \u2018untitled fit 1\u2019.\u201d<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 832px; height: 468px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_16.gif\" alt=\"view_9.gif\" width=\"832\" height=\"468\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Note that this generated code also plots our model. Let\u2019s change some of the settings so the plot is more descriptive:<\/div>\n<ul style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Change the title to \u201cVape usage prediction\u201d,<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Plot the original data for comparison,<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Extend the range of where we want the fitted curve to be plotted, say 2010 to 2040 by specifying those years and then plotting that data,<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Add a legend for the original and fitted data,<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Add a descriptive Y axis label,<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Ensure the extended years are displayed in the plot.<\/li>\n<\/ul>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 832px; height: 468px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_17.gif\" alt=\"view_10.gif\" width=\"832\" height=\"468\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Voila, we have our model for high school vape usage over the next 10+ years, addressing the first of two tasks for part 1 of this challenge. The model in question is a Gaussian, whose equation we see on the right in the &#8220;Curve Fitter&#8221; app: a1*exp(-((x-b1)\/c1)^2), with a1 = 31.9, b1 = 2023, c1 = 7.598. In our report we&#8217;ll want to report this model, which we&#8217;ll come back to at the end of this post. The code we generated is included here for reference (make sure the excel spreadsheets are located in the same folder as this Live Script):<\/div>\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 1px solid #bfbfbf; border-bottom: 0px none #212121; border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">NIHHSData = mean(NIHData(1:2,:))<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">mergedData = [HSData(1:end-1),NIHHSData]<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">years = 2011:2018<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">plot(years,mergedData)<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">%% Fit: &#8216;untitled fit 1&#8217;.<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">[xData, yData] = prepareCurveData( years, mergedData );<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Set up fittype and options.<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">ft = fittype( <span style=\"color: #a709f5;\">&#8216;gauss1&#8217; <\/span>);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts = fitoptions( <span style=\"color: #a709f5;\">&#8216;Method&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;NonlinearLeastSquares&#8217; <\/span>);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.Display = <span style=\"color: #a709f5;\">&#8216;Off&#8217;<\/span>;<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.Lower = [-Inf -Inf 0];<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.StartPoint = [24.2 2018 1.82425684047535];<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Fit model to data.<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">[fitresult, gof] = fit( xData, yData, ft, opts );<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Plot fit with data.<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">figure( <span style=\"color: #a709f5;\">&#8216;Name&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;Vape usage prediction&#8217; <\/span>); <span style=\"color: #008013;\">%change the title<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">plot(years,mergedData) <span style=\"color: #008013;\">%plot the original data<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">hold <span style=\"color: #a709f5;\">on <\/span><span style=\"color: #008013;\">% don&#8217;t generate a new figure when we plot other stuff <\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">extendedYears = 2010:2040; <span style=\"color: #008013;\">%extend the range of the prediction<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">plot(extendedYears,fitresult(extendedYears))<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">%fitresult is a function, so fitresult(extendedYears) are the values of our<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">%model on the values in the array extendedYears<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">legend(<span style=\"color: #a709f5;\">&#8216;HS vaping data&#8217;<\/span>,<span style=\"color: #a709f5;\">&#8216;model prediction&#8217; <\/span>); <span style=\"color: #008013;\">%add a legend for the original and fitted data <\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Label axes<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">xlabel( <span style=\"color: #a709f5;\">&#8216;years&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;Interpreter&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;none&#8217; <\/span>);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">ylabel( <span style=\"color: #a709f5;\">&#8216;percentage of HS students vaping&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;Interpreter&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;none&#8217; <\/span>); <span style=\"color: #008013;\">%add a descriptive label<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">xlim([2010 2040]) <span style=\"color: #008013;\">% ensure the extended years are displayed in the plot<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 1px solid #bfbfbf; border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">grid <span style=\"color: #a709f5;\">on<\/span><\/span><\/div>\n<\/div>\n<\/div>\n<h2 id=\"H_B1B802F6\" style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Comparing to historical data<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The other task for part 1 is to compare the HS cigarette usage to the historical trend, and the strategy we&#8217;ll start with is fitting a Gaussian to that data and comparing to the historical trend. This would provide further evidence that<\/div>\n<ol style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">the NIH data is reliable, and<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">the Gaussian is a reasonable model to use for cigarette usage and, hence, vape usage.<\/li>\n<\/ol>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">To do this we\u2019ll use the same pipeline as above:<\/div>\n<ul style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">use MATLAB\u2019s mean function to average the third and fourth rows of NIHdata, which have the cigarette usage data for 10th and 12th graders from 2015 to 2018,<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">use the curve fitter app to fit a Gaussian to the data.<\/li>\n<\/ul>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The first step looks just like it did before: isolate the 10th and 12th grade cigarette usage data and take the column-wise mean to get our HS cigarette usage estimate.<\/div>\n<div class=\"preformatted-matlab\" style=\"margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;\">\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">cigYears = 2015:2018;<\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">cigData = NIHData(3:4,:); <\/span><\/div>\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">cigDataHS = mean(cigData)<\/span><\/div>\n<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The second step looks similar to before: open up the curve fitter app, specify the x and y data to use, and choose \u201cGaussian\u201d under \u201cFit Type\u201d. Note that we also specified a new vector with just the years 2015 &#8211; 2018, since we&#8217;ll need to tell the curve fitter app which X data we want to use and the Y data in this case isn&#8217;t the entire period 2011-2018.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 780px; height: 544px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_18.png\" alt=\"view_13.png\" width=\"780\" height=\"544\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">When we zoom out this time, however, the model looks a little less realistic: this Gaussian suggests that HS cigarette usage peaked around 2012, and around 1996 was close to 0 percent usage. We would probably expect to see a higher percentage of HS cigarette usage further back in time, so maybe we won\u2019t include this model in our report just yet. One possible reason for this model not matching our expectations is that the amount of data we used is relatively small: in the vape usage model we had 8 data points to fit our model with, whereas here we only have 4. We\u2019ll go ahead and save the code and figure we generated so they\u2019re easy to return to. As we did above, we\u2019ll change some of the settings so the plot is more descriptive:<\/div>\n<ul style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Change the title to \u201cVape usage prediction\u201d<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Plot the original data for comparison<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Extend the range of where we want the fitted curve to be plotted, say 1990 to 2020 by specifying those years and then plotting that data<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Add a legend for the original and fitted data<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Add a descriptive Y axis label<\/li>\n<\/ul>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 780px; height: 440px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27_19.png\" alt=\"view_14.png\" width=\"780\" height=\"440\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">We&#8217;re not ready to include this model or plot in our report, but at least we have the code ready to go and modify if\/when we find supplementary data to improve our model. The code we generated is included here for reference (make sure the excel spreadsheets are located in the same folder as this Live Script):<\/div>\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 1px solid #bfbfbf; border-bottom: 0px none #212121; border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">cigYears = 2015:2018;<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">cigData = NIHData(3:4,:); <\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">cigDataHS = mean(cigData)<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">%% Fit: &#8216;untitled fit 1&#8217;.<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">[xData, yData] = prepareCurveData( cigYears, cigDataHS );<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Set up fittype and options.<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">ft = fittype( <span style=\"color: #a709f5;\">&#8216;gauss1&#8217; <\/span>);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts = fitoptions( <span style=\"color: #a709f5;\">&#8216;Method&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;NonlinearLeastSquares&#8217; <\/span>);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.Display = <span style=\"color: #a709f5;\">&#8216;Off&#8217;<\/span>;<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.Lower = [-Inf -Inf 0];<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">opts.StartPoint = [8.85 2015 2.00542812275561];<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Fit model to data.<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">[fitresult, gof] = fit( xData, yData, ft, opts );<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Plot fit with data.<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">figure( <span style=\"color: #a709f5;\">&#8216;Name&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;Cigarette usage prediction&#8217; <\/span>); <span style=\"color: #008013;\">% change the title<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">plot(cigYears,cigDataHS); <span style=\"color: #008013;\">%plot the original data<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">hold <span style=\"color: #a709f5;\">on<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">extendedYears = 1990:2020; <span style=\"color: #008013;\">% specify an extended plot range earlier in time <\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">plot(extendedYears, fitresult(extendedYears)); <\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% fitresult is a function, so fitresult(extendedYears) are the values of our model on earlier years<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">legend(<span style=\"color: #a709f5;\">&#8216;HS cigarette data&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;model prediction&#8217;<\/span>,<span style=\"color: #a709f5;\">&#8216;Location&#8217;<\/span>,<span style=\"color: #a709f5;\">&#8216;northwest&#8217;<\/span>) <span style=\"color: #008013;\">% add a legend<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Label axes<\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">xlabel( <span style=\"color: #a709f5;\">&#8216;cigYears&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;Interpreter&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;none&#8217; <\/span>);<\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">ylabel( <span style=\"color: #a709f5;\">&#8216;cigDataHS&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;Interpreter&#8217;<\/span>, <span style=\"color: #a709f5;\">&#8216;none&#8217; <\/span>); <span style=\"color: #008013;\">%add a descriptive Y axis label <\/span><\/span><\/div>\n<\/div>\n<div class=\"inlineWrapper\">\n<div style=\"border-left: 1px solid #bfbfbf; border-right: 1px solid #bfbfbf; border-top: 0px none #212121; border-bottom: 1px solid #bfbfbf; border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">grid <span style=\"color: #a709f5;\">on<\/span><\/span><\/div>\n<\/div>\n<\/div>\n<h2 id=\"H_E48C31F5\" style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Summary of progress and next steps<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">One aspect of the competition not yet discussed is the fact that it\u2019s a team effort, in that (likely) it will be you and 1-3 of your colleagues tackling this question together. So, as you and your teammates continue on in the day, one task someone could take on is to refine the cigarette usage model. This might mean finding more data points to build a more accurate model, or trying a different curve to fit the model, or exploring a completely different approach! We could also revisit the model we&#8217;re happy with to show we tried other reasonable models; polynomials didn&#8217;t seem to give us reasonable results, but maybe a logistic curve or Weibull curve (whatever that is) would give other reasonable models.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Another task for a teammate could be to revisit and add justification to the two assumptions we wrote down: does per capita cigarette usage correlate with with number of cigarette users (maybe as a percentage of total population)? can we find data about number or percentage of cigarette users throughout history, maybe even HS cigarette usage data or charts? Why are the National Youth Tobacco Survey and NIH Drug Trends datasets comparable\/mergeable? Etc.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">At this point we\u2019ve more-or-less answered part 1, at least enough for us to be comfortable that we have something we can write about and so we can get started on part 2 of the question. Before reading and starting on part 2, let\u2019s collect our thoughts and outline our solution (so far) to part 1:<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-style: italic;\">To model the spread of nicotine usage due to vaping over the next 10 years, we use survey data from the National Youth Tobacco Survey and NIH to fit a Gaussian model on percentage of HS students vaping: <\/span><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-style: italic;\">percentage of HS students vaping = a1*exp(-((x-b1)\/c1)^2), <\/span><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-style: italic;\">where a1 = 31.9, b1 = 2023, c1 = 7.598, and x is the year of interest. Our model predicts vaping usage will peak with approximately 32% of HS students vaping by the year 2023, afterwhich usage will decline until nearly 0% usage by 2040. The rest of this section describes in more detail our methods and assumptions that support this model. [Here we would include assumptions, discuss the model development including the rational for choosing a Gaussian, etc.]<\/span><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">We&#8217;re not done with part 1, but we have a solid start. Make sure to check out <a href=\"https:\/\/blogs.mathworks.com\/student-lounge\/2023\/02\/23\/youve-got-to-be-modeling-me-analysis-of-past-submissions\/\">part 2<\/a> that examines some student submissions to this challenge, and some of the models their teams built!<\/div>\n<\/div>\n<p><script type=\"text\/javascript\">var css = ''; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text\/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }<\/script><a href=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/23Jan27.mlx\"><button class=\"btn btn-sm btn_color_blue pull-right add_margin_10\">Download Live Script<\/button><\/a><div class=\"pull-right\"><div class=\"col-xs-12 containing-block\"><a href=\"#\" class=\"btn btn-sm btn_color_blue add_margin_20  hidden-xs try_live_editor_example\" data-liveeditorexample=\"{\n  &quot;repository&quot; : &quot;Blogs&quot;,\n  &quot;id&quot; : &quot;\/student-lounge\/files\/2023\/01\/23Jan27.mlx&quot;\n}\"><span class=\"icon-edit icon_16\"><\/span>Run in your browser<span style=\"color:grey\" class=\"series\"><\/span><\/a><\/div><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2023\/01\/Picture1.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div>\n<p>Joining us today is Wesley Hamilton, who is a STEM Outreach Engineer here at MathWorks. Wesley will talk about tackling the 2019 MathWorks Math Modeling Challenge (M3C) problem. Wesley, over to&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/student-lounge\/2023\/01\/27\/youve-got-to-be-modeling-me\/\">read more >><\/a><\/p>\n","protected":false},"author":183,"featured_media":9411,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[487,6],"tags":[438,639],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/9336"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/users\/183"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/comments?post=9336"}],"version-history":[{"count":8,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/9336\/revisions"}],"predecessor-version":[{"id":11900,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/9336\/revisions\/11900"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/media\/9411"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/media?parent=9336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/categories?post=9336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/tags?post=9336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}