[SOLVED] 程序代写代做代考 Welcome to the Institute for Digital Research and Education

30 $

File Name: 程序代写代做代考_Welcome_to_the_Institute_for_Digital_Research_and_Education.zip
File Size: 791.28 KB

SKU: 8945486025 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


Welcome to the Institute for Digital Research and Education
Institute for Digital Research and Education Home
Help the Stat Consulting Group by
Top of Form

Bottom of Form
Top of Form

Bottom of Form
· stat >
· r >
· dae
> logit.htm
R Data Analysis Examples: Logit Regression
Logistic regression, also called a logit model, is used to model dichotomous outcome variables. In the logit model the log odds of the outcome is modeled as a linear combination of the predictor variables.
This page uses the following packages. Make sure that you can load them before trying to run the examples on this page. If you do not have a package installed, run: install.packages(“packagename”), or if you see the version is out of date, run: update.packages().
library(aod)
library(ggplot2)
Version info: Code for this page was tested in R version 3.0.2 (2013-09-25)
On: 2013-12-16
With: knitr 1.5; ggplot2 0.9.3.1; aod 1.3
Please note: The purpose of this page is to show how to use various data analysis commands. It does not cover all aspects of the research process which researchers are expected to do. In particular, it does not cover data cleaning and checking, verification of assumptions, model diagnostics and potential follow-up analyses.
Examples
Example 1. Suppose that we are interested in the factors that influence whether a political candidate wins an election. The outcome (response) variable is binary (0/1); win or lose. The predictor variables of interest are the amount of money spent on the campaign, the amount of time spent campaigning negatively and whether or not the candidate is an incumbent.
Example 2. A researcher is interested in how variables, such as GRE (Graduate Record Exam scores), GPA (grade point average) and prestige of the undergraduate institution, effect admission into graduate school. The response variable, admit/don’t admit, is a binary variable.
Description of the data
For our data analysis below, we are going to expand on Example 2 about getting into graduate school. We have generated hypothetical data, which can be obtained from our website from within R. Note that R requires forward slashes (/) not back slashes () when specifying a file location even if the file is on your hard drive.
mydata <- read.csv(“http://www.ats.ucla.edu/stat/data/binary.csv”)## view the first few rows of the datahead(mydata)## admit gregpa rank## 1 0 380 3.613## 2 1 660 3.673## 3 1 800 4.001## 4 1 640 3.194## 5 0 520 2.934## 6 1 760 3.002This dataset has a binary response (outcome, dependent) variable called admit. There are three predictor variables: gre, gpa and rank. We will treat the variables gre and gpa as continuous. The variable rank takes on the values 1 through 4. Institutions with a rank of 1 have the highest prestige, while those with a rank of 4 have the lowest. We can get basic descriptives for the entire data set by using summary. To get the standard deviations, we use sapply to apply the sd function to each variable in the dataset.summary(mydata)##admitgre gparank ##Min. :0.000 Min. :220 Min. :2.26 Min. :1.00##1st Qu.:0.000 1st Qu.:520 1st Qu.:3.13 1st Qu.:2.00##Median :0.000 Median :580 Median :3.40 Median :2.00##Mean :0.318 Mean :588 Mean :3.39 Mean :2.48##3rd Qu.:1.000 3rd Qu.:660 3rd Qu.:3.67 3rd Qu.:3.00##Max. :1.000 Max. :800 Max. :4.00 Max. :4.00sapply(mydata, sd)## admit gre gparank ## 0.466 115.517 0.381 0.944## two-way contingency table of categorical outcome and predictors we want## to make sure there are not 0 cellsxtabs(~admit + rank, data = mydata)##rank## admit1234## 0 28 97 93 55## 1 33 54 28 12Analysis methods you might considerBelow is a list of some analysis methods you may have encountered. Some of the methods listed are quite reasonable while others have either fallen out of favor or have limitations.· Logistic regression, the focus of this page.· Probit regression. Probit analysis will produce results similar logistic regression. The choice of probit versus logit depends largely on individual preferences. · OLS regression. When used with a binary response variable, this model is known as a linear probability model and can be used as a way to describe conditional probabilities. However, the errors (i.e., residuals) from the linear probability model violate the homoskedasticity and normality of errors assumptions of OLS regression, resulting in invalid standard errors and hypothesis tests. For a more thorough discussion of these and other problems with the linear probability model, see Long (1997, p. 38-40).· Two-group discriminant function analysis. A multivariate method for dichotomous outcome variables.· Hotelling’s T2. The 0/1 outcome is turned into the grouping variable, and the former predictors are turned into outcome variables. This will produce an overall test of significance but will not give individual coefficients for each variable, and it is unclear the extent to which each “predictor” is adjusted for the impact of the other “predictors.”Using the logit modelThe code below estimates a logistic regression model using the glm (generalized linear model) function. First, we convert rank to a factor to indicate that rank should be treated as a categorical variable.mydata$rank <- factor(mydata$rank)mylogit <- glm(admit ~ gre + gpa + rank, data = mydata, family = “binomial”)Since we gave our model a name (mylogit), R will not produce any output from our regression. In order to get the results we use the summary command:summary(mylogit)## ## Call:## glm(formula = admit ~ gre + gpa + rank, family = “binomial”, ## data = mydata)## ## Deviance Residuals: ##Min1QMedian3Q Max## -1.627-0.866-0.639 1.149 2.079## ## Coefficients:## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -3.989981.13995 -3.500.00047 ***
## gre0.002260.001092.070.03847 *
## gpa0.804040.331822.420.01539 *
## rank2 -0.675440.31649 -2.130.03283 *
## rank3 -1.340200.34531 -3.880.00010 ***
## rank4 -1.551460.41783 -3.710.00020 ***
## —
## Signif. codes:0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ‘ 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 499.98on 399degrees of freedom
## Residual deviance: 458.52on 394degrees of freedom
## AIC: 470.5
##
## Number of Fisher Scoring iterations: 4
· In the output above, the first thing we see is the call, this is R reminding us what the model we ran was, what options we specified, etc.
· Next we see the deviance residuals, which are a measure of model fit. This part of output shows the distribution of the deviance residuals for individual cases used in the model. Below we discuss how to use summaries of the deviance statistic to assess model fit.
· The next part of the output shows the coefficients, their standard errors, the z-statistic (sometimes called a Wald z-statistic), and the associated p-values. Both gre and gpa are statistically significant, as are the three terms for rank. The logistic regression coefficients give the change in the log odds of the outcome for a one unit increase in the predictor variable.
· For every one unit change in gre, the log odds of admission (versus non-admission) increases by 0.002.
· For a one unit increase in gpa, the log odds of being admitted to graduate school increases by 0.804.
· The indicator variables for rank have a slightly different interpretation. For example, having attended an undergraduate institution with rank of 2, versus an institution with a rank of 1, changes the log odds of admission by -0.675.
· Below the table of coefficients are fit indices, including the null and deviance residuals and the AIC. Later we show an example of how you can use these values to help assess model fit.
We can use the confint function to obtain confidence intervals for the coefficient estimates. Note that for logistic models, confidence intervals are based on the profiled log-likelihood function. We can also get CIs based on just the standard errors by using the default method.
## CIs using profiled log-likelihood
confint(mylogit)
## Waiting for profiling to be done…
## 2.5 % 97.5 %
## (Intercept) -6.271620 -1.79255
## gre0.0001380.00444
## gpa0.1602961.46414
## rank2 -1.300889 -0.05675
## rank3 -2.027671 -0.67037
## rank4 -2.400027 -0.75354
## CIs using standard errors
confint.default(mylogit)
##2.5 % 97.5 %
## (Intercept) -6.22424 -1.75572
## gre0.000120.00441
## gpa0.153681.45439
## rank2 -1.29575 -0.05513
## rank3 -2.01699 -0.66342
## rank4 -2.37040 -0.73253
We can test for an overall effect of rank using the wald.test function of the aod library. The order in which the coefficients are given in the table of coefficients is the same as the order of the terms in the model. This is important because the wald.test function refers to the coefficients by their order in the model. We use the wald.test function. b supplies the coefficients, while Sigma supplies the variance covariance matrix of the error terms, finally Terms tells R which terms in the model are to be tested, in this case, terms 4, 5, and 6, are the three terms for the levels of rank.
wald.test(b = coef(mylogit), Sigma = vcov(mylogit), Terms = 4:6)
## Wald test:
## ———-
##
## Chi-squared test:
## X2 = 20.9, df = 3, P(> X2) = 0.00011
The chi-squared test statistic of 20.9, with three degrees of freedom is associated with a p-value of 0.00011 indicating that the overall effect of rank is statistically significant.
We can also test additional hypotheses about the differences in the coefficients for the different levels of rank. Below we test that the coefficient for rank=2 is equal to the coefficient for rank=3. The first line of code below creates a vector l that defines the test we want to perform. In this case, we want to test the difference (subtraction) of the terms for rank=2 and rank=3 (i.e., the 4th and 5th terms in the model). To contrast these two terms, we multiply one of them by 1, and the other by -1. The other terms in the model are not involved in the test, so they are multiplied by 0. The second line of code below uses L=l to tell R that we wish to base the test on the vector l (rather than using the Terms option as we did above).
l <- cbind(0, 0, 0, 1, -1, 0)wald.test(b = coef(mylogit), Sigma = vcov(mylogit), L = l)## Wald test:## ———-## ## Chi-squared test:## X2 = 5.5, df = 1, P(> X2) = 0.019
The chi-squared test statistic of 5.5 with 1 degree of freedom is associated with a p-value of 0.019, indicating that the difference between the coefficient for rank=2 and the coefficient for rank=3 is statistically significant.
You can also exponentiate the coefficients and interpret them as odds-ratios. R will do this computation for you. To get the exponentiated coefficients, you tell R that you want to exponentiate (exp), and that the object you want to exponentiate is called coefficients and it is part of mylogit (coef(mylogit)). We can use the same logic to get odds ratios and their confidence intervals, by exponentiating the confidence intervals from before. To put it all in one table, we use cbind to bind the coefficients and confidence intervals column-wise.
## odds ratios only
exp(coef(mylogit))
## (Intercept) gre gpa rank2 rank3 rank4
##0.01851.00232.23450.50890.26180.2119
## odds ratios and 95% CI
exp(cbind(OR = coef(mylogit), confint(mylogit)))
## Waiting for profiling to be done…
## OR 2.5 % 97.5 %
## (Intercept) 0.0185 0.001890.167
## gre 1.0023 1.000141.004
## gpa 2.2345 1.173864.324
## rank2 0.5089 0.272290.945
## rank3 0.2618 0.131640.512
## rank4 0.2119 0.090720.471
Now we can say that for a one unit increase in gpa, the odds of being admitted to graduate school (versus not being admitted) increase by a factor of 2.23. For more information on interpreting odds ratios see our FAQ page How do I interpret odds ratios in logistic regression? . Note that while R produces it, the odds ratio for the intercept is not generally interpreted.
You can also use predicted probabilities to help you understand the model. Predicted probabilities can be computed for both categorical and continuous predictor variables. In order to create predicted probabilities we first need to create a new data frame with the values we want the independent variables to take on to create our predictions.
We will start by calculating the predicted probability of admission at each value of rank, holding gre and gpa at their means. First we create and view the data frame.
newdata1 <- with(mydata, data.frame(gre = mean(gre), gpa = mean(gpa), rank = factor(1:4)))## view data framenewdata1## gregpa rank## 1 588 3.391## 2 588 3.392## 3 588 3.393## 4 588 3.394These objects must have the same names as the variables in your logistic regression above (e.g. in this example the mean for gre must be named gre). Now that we have the data frame we want to use to calculate the predicted probabilities, we can tell R to create the predicted probabilities. The first line of code below is quite compact, we will break it apart to discuss what various components do. The newdata1$rankP tells R that we want to create a new variable in the dataset (data frame) newdata1 called rankP, the rest of the command tells R that the values of rankP should be predictions made using the predict( ) function. The options within the parentheses tell R that the predictions should be based on the analysis mylogit with values of the predictor variables coming from newdata1 and that the type of prediction is a predicted probability (type=”response”). The second line of the code lists the values in the data frame newdata1. Although not particularly pretty, this is a table of predicted probabilities.newdata1$rankP <- predict(mylogit, newdata = newdata1, type = “response”)newdata1## gregpa rank rankP## 1 588 3.391 0.517## 2 588 3.392 0.352## 3 588 3.393 0.219## 4 588 3.394 0.185In the above output we see that the predicted probability of being accepted into a graduate program is 0.52 for students from the highest prestige undergraduate institutions (rank=1), and 0.18 for students from the lowest ranked institutions (rank=4), holding gre and gpa at their means. We can do something very similar to create a table of predicted probabilities varying the value of gre and rank. We are going to plot these, so we will create 100 values of gre between 200 and 800, at each value of rank (i.e., 1, 2, 3, and 4).newdata2 <- with(mydata, data.frame(gre = rep(seq(from = 200, to = 800, length.out = 100),4), gpa = mean(gpa), rank = factor(rep(1:4, each = 100))))The code to generate the predicted probabilities (the first line below) is the same as before, except we are also going to ask for standard errors so we can plot a confidence interval. We get the estimates on the link scale and back transform both the predicted values and confidence limits into probabilities.newdata3 <- cbind(newdata2, predict(mylogit, newdata = newdata2, type = “link”,se = TRUE))newdata3 <- within(newdata3, {PredictedProb <- plogis(fit)LL <- plogis(fit – (1.96 * se.fit))UL <- plogis(fit + (1.96 * se.fit))})## view first few rows of final datasethead(newdata3)## gregpa rankfit se.fit residual.scaleULLL PredictedProb## 1 200 3.391 -0.8110.5151 0.549 0.139 0.308## 2 206 3.391 -0.7980.5091 0.550 0.142 0.311## 3 212 3.391 -0.7840.5031 0.551 0.145 0.313## 4 218 3.391 -0.7700.4981 0.551 0.149 0.316## 5 224 3.391 -0.7570.4921 0.552 0.152 0.319## 6 230 3.391 -0.7430.4871 0.553 0.155 0.322It can also be helpful to use graphs of predicted probabilities to understand and/or present the model. We will use the ggplot2 package for graphing. Below we make a plot with the predicted probabilities, and 95% confidence intervals.ggplot(newdata3, aes(x = gre, y = PredictedProb)) + geom_ribbon(aes(ymin = LL,ymax = UL, fill = rank), alpha = 0.2) + geom_line(aes(colour = rank),size = 1)We may also wish to see measures of how well our model fits. This can be particularly useful when comparing competing models. The output produced by summary(mylogit) included indices of fit (shown below the coefficients), including the null and deviance residuals and the AIC. One measure of model fit is the significance of the overall model. This test asks whether the model with predictors fits significantly better than a model with just an intercept (i.e., a null model). The test statistic is the difference between the residual deviance for the model with predictors and the null model. The test statistic is distributed chi-squared with degrees of freedom equal to the differences in degrees of freedom between the current and the null model (i.e., the number of predictor variables in the model). To find the difference in deviance for the two models (i.e., the test statistic) we can use the command: with(mylogit, null.deviance – deviance)## [1] 41.5The degrees of freedom for the difference between the two models is equal to the number of predictor variables in the mode, and can be obtained using:with(mylogit, df.null – df.residual)## [1] 5Finally, the p-value can be obtained using:with(mylogit, pchisq(null.deviance – deviance, df.null – df.residual, lower.tail = FALSE))## [1] 7.58e-08The chi-square of 41.46 with 5 degrees of freedom and an associated p-value of less than 0.001 tells us that our model as a whole fits significantly better than an empty model. This is sometimes called a likelihood ratio test (the deviance residual is -2*log likelihood). To see the model’s log likelihood, we type:logLik(mylogit)## ‘log Lik.’ -229 (df=6)Things to consider· Empty cells or small cells: You should check for empty or small cells by doing a crosstab between categorical predictors and the outcome variable. If a cell has very few cases (a small cell), the model may become unstable or it might not run at all. · Separation or quasi-separation (also called perfect prediction), a condition in which the outcome does not vary at some levels of the independent variables. See our page FAQ: What is complete or quasi-complete separation in logistic/probit regression and how do we deal with them? for information on models with perfect prediction.· Sample size: Both logit and probit models require more cases than OLS regression because they use maximum likelihood estimation techniques. It is sometimes possible to estimate models for binary outcomes in datasets with only a small number of cases using exact logistic regression. It is also important to keep in mind that when the outcome is rare, even if the overall dataset is large, it can be difficult to estimate a logit model.· Pseudo-R-squared: Many different measures of psuedo-R-squared exist. They all attempt to provide information similar to that provided by R-squared in OLS regression; however, none of them can be interpreted exactly as R-squared in OLS regression is interpreted. For a discussion of various pseudo-R-squareds see Long and Freese (2006) or our FAQ page What are pseudo R-squareds?· Diagnostics: The diagnostics for logistic regression are different from those for OLS regression. For a discussion of model diagnostics for logistic regression, see Hosmer and Lemeshow (2000, Chapter 5). Note that diagnostics done for logistic regression are similar to those done for probit regression.ReferencesHosmer, D. & Lemeshow, S. (2000). Applied Logistic Regression (Second Edition). New York: John Wiley & Sons, Inc.Long, J. Scott (1997). Regression Models for Categorical and Limited Dependent Variables. Thousand Oaks, CA: Sage Publications.See also· R Online Manual glm· Stat Books for Loan, Logistic Regression and Limited Dependent Variables· Everitt, B. S. and Hothorn, T. A Handbook of Statistical Analyses Using R· © 2015 UC Regents· Terms of Use & Privacy PolicyWelcome to the Institute for Digital Research and EducationInstitute for Digital Research and Education Home Help the Stat Consulting Group by Top of FormBottom of FormTop of FormBottom of Form· stat >
· r >
· dae
> nbreg.htm
R Data Analysis Examples: Negative Binomial Regression
Negative binomial regression is for modeling count variables, usually for over-dispersed count outcome variables.
This page uses the following packages. Make sure that you can load them before trying to run the examples on this page. If you do not have a package installed, run: install.packages(“packagename”), or if you see the version is out of date, run: update.packages().
require(foreign)
require(ggplot2)
require(MASS)
Version info: Code for this page was tested in R Under development (unstable) (2013-01-06 r61571)
On: 2013-01-22
With: MASS 7.3-22; ggplot2 0.9.3; foreign 0.8-52; knitr 1.0.5
Please note: The purpose of this page is to show how to use various data analysis commands. It does not cover all aspects of the research process which researchers are expected to do. In particular, it does not cover data cleaning and checking, verification of assumptions, model diagnostics or potential follow-up analyses.
Examples of negative binomial regression
Example 1. School administrators study the attendance behavior of high school juniors at two schools. Predictors of the number of days of absence include the type of program in which the student is enrolled and a standardized test in math.
Example 2. A health-related researcher is studying the number of hospital visits in past 12 months by senior citizens in a community based on the characteristics of the individuals and the types of health plans under which each one is covered.
Description of the data
Let’s pursue Example 1 from above.
We have attendance data on 314 high school juniors from two urban high schools in the file nb_data. The response variable of interest is days absent, daysabs. The variable math gives the standardized math score for each student. The variable prog is a three-level nominal variable indicating the type of instructional program in which the student is enrolled.
Let’s look at the data. It is always a good idea to start with descriptive statistics and plots.
dat <- read.dta(“http://www.ats.ucla.edu/stat/stata/dae/nb_data.dta”)dat <- within(dat, {prog <- factor(prog, levels = 1:3, labels = c(“General”, “Academic”, “Vocational”))id <- factor(id)})summary(dat)##id gender math daysabs ##1001 :1 female:160 Min. : 1.0 Min. : 0.00##1002 :1 male:154 1st Qu.:28.0 1st Qu.: 1.00##1003 :1Median :48.0 Median : 4.00##1004 :1Mean :48.3 Mean : 5.96##1005 :13rd Qu.:70.0 3rd Qu.: 8.00##1006 :1Max. :99.0 Max. :35.00##(Other):308##prog##General : 40##Academic:167##Vocational:107######## ggplot(dat, aes(daysabs, fill = prog)) + geom_histogram(binwidth = 1) + facet_grid(prog ~ ., margins = TRUE, scales = “free”)Each variable has 314 valid observations and their distributions seem quite reasonable. The unconditional mean of our outcome variable is much lower than its variance. Let’s continue with our description of the variables in this dataset. The table below shows the average numbers of days absent by program type and seems to suggest that program type is a good candidate for predicting the number of days absent, our outcome variable, because the mean value of the outcome appears to vary by prog. The variances within each level of prog are higher than the means within each level. These are the conditional means and variances. These differences suggest that over-dispersion is present and that a Negative Binomial model would be appropriate. with(dat, tapply(daysabs, prog, function(x) {sprintf(“M (SD) = %1.2f (%1.2f)”, mean(x), sd(x))}))## GeneralAcademicVocational ## “M (SD) = 10.65 (8.20)””M (SD) = 6.93 (7.45)””M (SD) = 2.67 (3.73)”Analysis methods you might considerBelow is a list of some analysis methods you may have encountered. Some of the methods listed are quite reasonable, while others have either fallen out of favor or have limitations. · Negative binomial regression -Negative binomial regression can be used for over-dispersed count data, that is when the conditional variance exceeds the conditional mean. It can be considered as a generalization of Poisson regression since it has the same mean structure as Poisson regression and it has an extra parameter to model the over-dispersion. If the conditional distribution of the outcome variable is over-dispersed, the confidence intervals for the Negative binomial regression are likely to be narrower as compared to those from a Poisson regression model.· Poisson regression – Poisson regression is often used for modeling count data. Poisson regression has a number of extensions useful for count models. · Zero-inflated regression model – Zero-inflated models attempt to account for excess zeros. In other words, two kinds of zeros are thought to exist in the data, “true zeros” and “excess zeros”. Zero-inflated models estimate two equations simultaneously, one for the count model and one for the excess zeros.· OLS regression – Count outcome variables are sometimes log-transformed and analyzed using OLS regression. Many issues arise with this approach, including loss of data due to undefined values generated by taking the log of zero (which is undefined), as well as the lack of capacity to model the dispersion.Negative binomial regression analysisBelow we use the glm.nb function from the MASS package to estimate a negative binomial regression.summary(m1 <- glm.nb(daysabs ~ math + prog, data = dat))## ## Call:## glm.nb(formula = daysabs ~ math + prog, data = dat, init.theta = 1.032713156, ## link = log)## ## Deviance Residuals: ##Min1QMedian3Q Max## -2.155-1.019-0.369 0.229 2.527## ## Coefficients:##Estimate Std. Error z value Pr(>|z|)
## (Intercept) 2.615270.19746 13.24< 2e-16 ***## math -0.005990.00251 -2.390.017 *## progAcademic -0.440760.18261 -2.410.016 *## progVocational -1.278650.20072 -6.371.9e-10 ***## —## Signif. codes:0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ‘ 1## ## (Dispersion parameter for Negative Binomial(1.033) family taken to be 1)## ## Null deviance: 427.54on 313degrees of freedom## Residual deviance: 358.52on 310degrees of freedom## AIC: 1741## ## Number of Fisher Scoring iterations: 1## ## ## Theta:1.033 ## Std. Err.:0.106 ## ##2 x log-likelihood:-1731.258· R first displays the call and the deviance residuals. Next, we see the regression coefficients for each of the variables, along with standard errors, z-scores, and p-values. The variable math has a coefficient of -0.006, which is statistically significant. This means that for each one-unit increase in math, the expected log count of the number of days absent decreases by 0.006. The indicator variable shown as progAcademic is the expected difference in log count between group 2 and the reference group (prog=1). The expected log count for level 2 of prog is 0.44 lower than the expected log count for level 1. The indicator variable for progVocational is the expected difference in log count between group 3 and the reference group.The expected log count for level 3 of prog is 1.28 lower than the expected log count for level 1. To determine if prog itself, overall, is statistically significant, we can compare a model with and without prog. The reason it is important to fit separate models, is that unless we do, the overdispersion parameter is held constant.m2 <- update(m1, . ~ . – prog)anova(m1, m2)## Likelihood ratio tests of Negative Binomial Models## ## Response: daysabs## Modeltheta Resid. df2 x log-lik. Testdf LR stat.## 1math 0.8559 312 -1776## 2 math + prog 1.0327 310 -1731 1 vs 2 245.05## Pr(Chi)## 1## 2 1.652e-10· The two degree-of-freedom chi-square test indicates that prog is a statistically significant predictor of daysabs.· The null deviance is calculated from an intercept-only model with 313 degrees of freedom. Then we see the residual deviance, the deviance from the full model. We are also shown the AIC and 2*log likelihood. · The theta parameter shown is the dispersion parameter. Note that R parameterizes this differently from SAS, Stata, and SPSS. The R parameter (theta) is equal to the inverse of the dispersion parameter (alpha) estimated in these other software packages. Thus, the theta value of 1.033 seen here is equivalent to the 0.968 value seen in the Stata Negative Binomial Data Analysis Example because 1/0.968 = 1.033. Checking model assumptionAs we mentioned earlier, negative binomial models assume the conditional means are not equal to the conditional variances. This ine

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 程序代写代做代考 Welcome to the Institute for Digital Research and Education
30 $