estimation of linear regression using stata - stata

how to estimate linear regression using OLS with stata command 'regress', how to transform the slope of a in order to meet the following regression form
enter image description here
a=E/pib
regress bc a

I think your question seems to be about (1-b2).
After regress bc a, your coefficient is exactly 1-b2, so if you want to get b2, then just subtract it from 1 .

Related

Residual estimation for negative binomial regression in Stata

I am new to generalised linear modelling. I ran the negative binomial model, and then try to estimate the residuals from the model.
Here is what I did:
Run a negative binomial regression model with nbreg command in stata 17.
Run the predict command to estimate the predicted values.
Then, generate the residual by subtracting predicted values from observed values.
Did I do it correctly?

Putting a Regression Line When Using Pandas scatter_matrix

I'm using scatter_matrix for correlation visualization and calculating correlation values using corr(). Is it possible to have the scatter_matrix visualization draw the regression line in the scatter plots?
I think this is a misleading question/thought process.
If you think of data in strictly 2 dimension then a regression line on a scatter plot makes sense. But let's say you have 5 dimensions of data you are plotting in your scatter matrix. In this case the regression for each pair of dimensions is not an accurate representation of the global regression.
I would be wary presenting that to anyone as I can easily see where it could create confusion.
That being said if you don't care about a regression across all of your dimensions then you could write your own function to do this. A quick walk through of steps may be:
1. Identify number of dimensions N
2. Create figure
3. Double for loop on N, first will walk down rows, second will walk across rows
4. At each point add subplot, calculate regression (if not kde/hist position), plot scatter cloud and regression line or kde/hist

SAS Proc Logistic Selection=Score

I'm using PROC LOGISTIC procedure in SAS and option SELECTION=SCORE which gives me few logistic regression models and their Chi-Square values. My question would be which model is better - with smaller Chi-Square or bigger?
In general, the larger chi-squared statistic will correspond with a lower p-value (more significance). However, it is important to know the shape of the chi-squared distribution and also the number of degrees of freedom. As you can see in the graph, the relationship between p and chi-squared changes based on the degrees of freedom.
Score for Chi-Square is larger, the model is better.

estimate linear combination of regression coefficients in sas

I'm using a LMM in SAS and, I would like to get an estimation (and a p-value) of a linear combination of some of the regression coefficients.
Say that the model is:
b0+b1Time+b2X1+b3X2+b4(Time*X1)
and say that, I want to get an estimate and a p-value for the b1+b4.
What should I do?

Graphing individual marginal effects in Stata

I have a probit model and I'm trying to compute and plot the marginal effects of a continuous variable for all the observations in the sample.
I'm using Stata and I have five independent variables. The variable for which I would like to compute marginal effects for all individuals takes 9 possible integer values (0 to 8), and I treat it as continuous (not as a factor variable). The most common command for marginal effects seems to be margins:
margins, dydx(x) at(x=(0(1)8))
marginsplot
This command doesn't do what I would like to do. It seems to compute marginal effects for all individuals with x=0, x=1 and so forth and then average them for each value of x. The output I get reports a marginal effect and a standard error for each value of x.
I would like to obtain the marginal effect of x for each individual in the sample. Two individuals for whom x=0 should have different marginal effects if the other variables in the model take different values for these observations. How can compute and plot these effects?
You can estimate the model, predict, change x with replace, and predict again. Then you can calculate the differences between the two predictions to get the marginal effects. You can change x by 1 or by a small amount epsilon (which will approximate what margins calculates much better). The first version will obviously be larger.
Here's an example using the cars data:
set more off
sysuse auto, clear
keep foreign mpg rep78 make
clonevar orig_rep78 = rep78
probit foreign mpg rep78
margins, dydx(rep78)
predict phat, pr
replace rep78 = rep78 + 1
predict phat_plus_one, pr
gen double finite_diff = phat_plus_one - phat
replace rep78 = orig_rep78 + 0.01
predict phat_plus_eps, pr
gen double eps_diff = (phat_plus_eps - phat)/.01
drop rep78
rename orig_rep78 rep78
tw (scatter finite_diff mpg) (scatter eps_diff mpg)
sum *_diff
You can see that the eps version matches the margins output more closely. You might want to see how sensitive your estimates are to different values of epsilon.
I don't know what sort of graph you had in mind, so I just plotted the MEs against the other regressor. You can see that the ME is increasing in mpg, which makes sense since the index function coefficients are all positive. The low values for mpg above 30 make sense since the predicted probability is already near 1, so additional repairs can't raise it all that much.