






















Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!























Policy research question: does class size affect student learning and achievement? What is the effect on test scores (or some other outcome measure) of reducing class size by one student per class? By 8 student/class? If the class is too small you have schoolmates in your class who doesn’t fit with you The teacher can dedicate more time to the students but on the other side there are also some limitation on the student learning We can use a theoretical model THE CALIFORNIA TEST SCORE DATA SET It is make of K-6 and K-8 (correspond to elementary and junior high schooling Italy), California school district We want to study the correlation between school size and student achievement; we don’t have information about the single score of the student but about the average, second informations STR we refer to the class size (student to teacher ratio). If look at the STR we see average 19.6, standard deviation 1.9, smaller classe have 17.3% while largest ones have 90% students; test average score in. Maths is 654. maximum score is 8hundred, standard deviation reflects even the unit of measure of the variables; 50% is the median is the school district which is in the middle of our variable. This table doesn’t tell us anything about the relationship between test score and STR. (We have lot of information about separate variables) W hat can we do to see if there is a relation?
First we have to define which district we consider low size and large six so we divide the school districts in 2 groups: STR <20 and STR > 20 ( we consider the median, which is about 20). We could also choose to create more than 2 groups but the analysis will be more complicated. In this case statistics is meaningful from a statistics point of view. Let’s do the statistics analysis following the 3 parts we have seen before.
Provare a installare STATA Mercoledì prossimo inizio lezione alle 12:
We are looking at the distribution of a random variable and we can also compute the conditional moment such as the conditional means ( = the expectation of conditional distribution) E(Y|X =x) IMPORTANT CONCEPT OF NOTATION Conditional variance is the variance of the conditional distribution Delta is the difference = (conditional means of the test score with STR < 20) minus (the conditional means of the test score pf STR >= 20) I can compute the mortality rates of those who is texting a new vaccine for the covid, for example. When the conditional mean is constant, means the two variables are uncorrelated, so the 2 variables are independently distributed. The CONDITIONAL MEAN corresponds to the more intuitive idea of the group mean. CONDITIONAL MEANS AND PREDICITONS The conditional mean plays a key role in prediction For example you want to predict someone’s score given the STR M is pur prediction which can be a conditional mean but also other statistics MSPE= Mean square prediction error is simply the average of the expect value of the difference between the 2 variable (guarda formula tra parentesi sulla slide) DISTRIBUTION OF A SAMPLE OF DATA DRAWN RANDOMLY FROM A POPULATION In our case our population was the school district of the area. We assume that the sample of observation is a random sample of the initial population. Randomness of the data means that prior to sample selection which have a value of Y which is random because the individual selected is random. Y1 and Y2 are randomly selected for this reason they are INDEPENDENTLY DISTRIBUTED this the correlation is zero, n information pf individual 1 are available on the individual 2. If the individual come from the same population they are IDENTICALLY DISTRIBUTED; under simple random sampling Y1 and Y2 are independently and identically distributed (iid) ESTIMATION Y segnato sopra is the natural estimator of the mean Y is a random variable and its properties are determined by the SAMPLING DISTRIBUTION of Y segnato (sample = campione)
Make a provisional decision based on the evidence at hand and whether a null hypothesis is true, or instead that she alternative hypothesis is true. Now we want to test more formally whether a certain mean is actually equal or not to a specific value. We want to make a sort of previsional decision. Null hyphotesis in pur case the mean of the population is equal to a certain value. 1-sided test because we are comparing pour value with values which are grader or lower than it. We can also have a 2-sided statistical test SOME TERMINOLOGY P-VALUE= probability of drawing. Statistic at least as adverse to the null hypothesis, is a measure of the probability that you will reject the null hypothesis when the null hp is actually true SIGNIFICANCE LEVEL= is a pre-specified probability of rejecting null hp when the null is true. The most using critical significance level is 5%. (Foruma p-value) Can be defined as the porb that the absolute difference between the mean of the population (or another statistics from data) menus the value of the value of the null hp we are simply formally defined the definition of p-value. To compete the p-value we need to know the sampling distribution of Ybar which is complicated if n is small. If N is large we can use the normal distribution approximation. ESTIMATOR OF THE VARIANCE OF Y Usually e We test the null hyphptesis that mean is equal to zero, usually reject if the value of the t-statistic is in absolute value grader or equal to the critical level we associate to the the t-statistic used. The p-value is sometimes called the MARGINAL SIGNIFICANCE LEVEL. REGRESSION: THE STUDENT T DISTRIBUTION Compute the t-statistic with our data then we compute the degrees of freedom (N-1). However if the sample is relatively large (more than 30 observations), the t- distribution and standard normal distribution are very similar. CONFIDENCE INTERVALS A 95% confidence interval for the means is an interval that contains the true value of the population mean in 95% of repeated samples. However in a certain way this anther a random measure in pur analysis. We know the population mean value is not a random value. Slide con confidence intervals formula STATA LAB 1
Per aprire un file clicchiamo su File poi changing working directory e apro la cartella stata e poi clicco su open per aprire il file scelto We have all the variables on the right How to import data which are not in stata format Let’s tray to import the same dataset starting from the excel version Go to the menu file then import and excel spreadsheet and we choose our excel file, click okay and then flag the first of the two phrase. Se vogliamo cancellare il dataset ci basta scrivere CLEAR nei commands e le variabili spariranno e ogni volta che scrivo clear noi perdiamo tutto quindi prima di cliccarlo è meglio salvare tutto Quando importiamo un file da excel se stat torva una cella vuota allora metterà un punto. Essendo un programma statunitense invece della virgola avremo il punto nella scrittura dei numeri quindi verifichiamo che sia cosi anche nel nostro programma excel. With stata we can use data with multiple observations (ex consumer survey in 2019 or gdp per capital in 2020) I have many entities. x is the name of the variable IT= specific observation and T denotes a specific time period Panel or longitudinal data= when we work with panel data all the entities are observed in the all time period: x with index IT We will use mainly cross section data and pull cross section data Panel data requires more advanced econometrics techniques DESCRIBE : use it when we want to know some features about our data Apriamo ancora caschool.dta ma abbiamo bisogno del do file per conoscere meglio le variabili che abbiamo a disposizione. Quindi possiamo scrivere do edit nei command oppure andiamo in window e clicchiamo do edit. A questo punto nella pagina che si apre, clicchiamo sul do file che abbiamo. Ora dobbiamo scrivere le caratteristiche delle variabili Quando vogliamo scrivere commenti o appunti sul do file dobbiamo sempre iniziare con * e poi scrivere LIST = stat will show me in the main window how this variables look like List str testscr I want stata show me only these 2 variables Sottolineiamo il comando che vogliamo fare e poi clicchiamo su execute selection (ultima icona a destra). Quindi otteniamo la lista delle due variabili che avevamo richiesto nelle 10 osservazioni richieste. Il primo numero si riferisce alla linea in cui
I also have percentages by column, when you scroll down you see that the corresponding final percentage is 100% cell= prende invece la cella Row = prende la riga Row col cell Row sort =list rows in order of observed frequencies Colsort =list of columns in order of observed frequencies How can we get graphs on stata Histograms is the graphical representation of the frequency table: command histograms , to save the graphic I need to command graph save ( gph= graph Graph box to obtain the box plot 21/ Data management To create a new variable is GENERATE or GEN , the name of the new variables = Alternatively to create a dummy in stata we can start generate str_20bis=1 if str>20 /school district with a large class size =1) EGEN= extended generate command RENAME = rename the variable LABEL data = will create a label for the entire data set Before the need to create the label and then we can attach it to a specific variable LABEL DEFINE = Using labels is useful oof you want to give more information to the dataset or the variables names If we want to change the order of the variables we need the command ORDER and then we specify the order of the variable SORT stata will sort in ascending order my observations using first county HOMEWORK
Continuiamo ad analizzare i comandi inseriti nel do-file PRESERVE= RESTORE= stat will go back to the initial data set I had before the preserve command If you don’t want to use preserve or restore command you can simply ask stata to open again the school dataset and run what you need to run and then reopen again the initial dataset.
grader < below = equal When we add other variables coming from other dataset is like we are merging 2 dataset. MERGE is the command we should use We can do it if they refers to different units of analysis FLEXIBLE TABLE in stata, table in which we put some variables but the content of the table maybe be variables statistically computed with our variables in our table. The command is TABLE for ex table county; but we can specific the variable for the row and the variable for the column, then we need to specify the content of our table C= CONTENT Quindi scriviamo C( e all’interno scriviamo il contenuto che vogliamo, per esempio COUNT dist_cod) vogliamo contare il numero di district
Under the assumptions x an epsilon independent, the error term mean is equal to zero, constant covariance and no serial correlation, the estimator is: consistent, asymptotically normal, routinely computed standard errors are (approximately) correct. EXAMPLE The California test score data TESTSCORE= 698.9 - 2.28STR (Student to teacher ratio) They may be other factors correlated to the class size which can have a direct effect, these factors are all in the error term How can we get this result on Stata? To get OLS estimates we use the stata command REG (regresse) then we need to specify the model (testscr) and the following variable is the x (Pctel) ROBUST (to get what we call heteroskedasticity- robust standard errors) MEASURE OF FIT FOR MULTIPLE REGRESSION SER = Standard errors of Regression= standard deviation of u (with degrees of freedom correction) Root MSE = RMSE= standard deviation of u (without degrees freedom correction) R^2 = fractions of variance of Y explained by X R^2 segnato= adjusted R^2= R^2 with degrees of freedom correction that adjusts for estimation uncertainty (R-squared) Formula of SER and RMSE on the slide ESS = Explained Sum of Squares We can computing the adjusting r squared which corrects this problem by penalizing you for including another regressor (formula per il calcolo di adjusted r squared) Penalization term is (n-1)/(n-k-1) 1)R^2= 0.5 SER= 18. Ser depend on the unit of measure of the variables, to understand if is large or small it is important to compare it with the standard deviation
We can detect heteroskedasticity on the dataset thanks to the graphics 28/ MULTIPLE REGRESSION IN STATA We can see the comment REG = regress We are interested in the relationship between the class size and the student tot teacher ratio, ROBUST compute heteroskedasticity robust standard errors. The square root of the k^th diagonal element is the standard error of Bk. If sigma^” (variance of the error term) Is constant then we have homoskedasticity, however if the variance of the error term is not constant, in this case we have computed standards numbers. COMPUTING ROBUST STANDARD ERRORS (Formula on the slide represent the matrix which can be computed from he regressor and the Ols residuals. Two ways to computing standard errors.
H0: no confirmation of the virus H1: confirmation of the virus Type 1 error —> false positive Type 2 error —> false negative What error should be minimized? The aim is to minimize the spread of the disease, so it is reasonable to minimize the type 2 error, it’s not neutral to minimize the type 1 error. (In the paper they recommend to implement more rapid test that are very accurate to identify people who have not the disease but not very good to find people which are ill).
Summarize = basically statistic for a specify variable Summarize with the option ,D = detail it gives more informations about percentiles and moment of the distribution. If we are interested only in mean but we also want an estimation we can use the command MEAN (and variable list) Example MEAN TESTSCR we obtain the mean, the standard error of the mean and the 95% confidence interval. But we can also change the significance level of the confidence interval we have to start with CI (CONFIDENCE INTERVAL) then MEAN and the variable and coma, specifying the new significance level :level(99). T-TEST = also without running regression; Ex: test testscr, by ( str_20); (BY is important to create the two group, is the name used by stata to provide statistic for different groups) in brackets I specify the variable. UNEQUAL =I allow stata to consider unequal variance in the mean between the 2 groups, being more flexible in the t-test. Sample (want to randomly selected 182 observations) PAIRED T-TEST = asl stata to test wether the mean in read score is equal to maths test score PAIRWAISE CORRELATION
Hypothesis tests and confidence intervals are now implemented and interpreted “as usual”. The interpretation of beta1 differs from case to case. The choice of specification should be guided by judgement, test and plotting predicted values. OTHER NONLINEAR FUNCTIONS (AND NONLINEAR LEAST SQUARES) The following regression functions have limitations
Pheraphs a class size reduction is more effective in some circumstances than in others. We will first consider binary X’s then continuous X’s. Can you relate these coefficients to the following table of group means? Substituting the value of the 2 dummy variables, if both are low Once you know how to obtain the expected value starting from the coefficient then we can compute also other differential effects, like I am computed the expected effect INTERACTION BETWEEN CONTINUOUS AND BINARY VARIABLES D (dummy variable) is binary while X is continuous; the effect on Y of X = beta which does not depend on D), how can we interpret the coefficients? It is like we can get 2 different regression line, a regression line for group of observations D =0 and the second regression line for subgroups pf observations in which D = 1. If we want to take the marginal effect of x on y : deltaY/deltaX. The effect of X depends on D When D=1, beta3 is equal to the increment to the effect of X. Grafico 1) dummy variable is equal to zero, D=1 , beta3 is equal to zero but beta different from zero