Does following code correctly execute the Breusch-Pagan test, and if not, what is the error?
proc reg data = mydataset;
TITLE 1 "The following is the Breusch-Pagan test for Constant Variance";
model Y = X1;
output out = newdataset r = resid;
run;
data BP;
set newdataset;
e2 = log10(resid*resid);
run;
proc reg data = BP;
model e2 = X1; * The p-value of the beta-coefficient for X1 is the BP test p-value;
run;
I was told to run the test this way, but it is producing unexpected results. I'd like some third-party validation. (I'm aware that PROC Model has a built-in Breusch-Pagan test. That is not my question.)
SAS uses a modified version of the Breusch-Pagan test that relaxes (but doesn't eliminate) normality assumptions. The way in which you are testing it is not exactly the same way that SAS is doing it. SAS's version of the B-P test and the equation for the test statistic is documented on their website.
This is a modified version of the Breusch-Pagan test, which is less sensitive to the assumption of normality than the original test (Greene 1993, p. 395).
Source
Related
I try to run stepwise regression in sas with 2.9M rows with 300 columns. I am getting below error.
ERROR: Event Stack Overflow. This is probably caused by mis-matched begin and end event calls.
My Code is
* Forward Selection;
proc reg data =work.bs_bm_final_data outest=est1;
model y = A_004 - A_300 / selection = forward slentry = 0.99 ss2 sse aic;
output out=out1 p=p r=r; run; quit;
This may be a problem with your version of SAS or something around your machine's configuration. For a server this would be a relatively small dataset but for a consumer desktop or laptop it could be too much.
Can you try running proc glmselect instead and see if it works? The adapted code is below.
proc glmselect data=sashelp.cars;
model y = A_004 - A_300 / selection=forward(sle=0.99) showpvalues;
output out=out p=p r=r;
run;
Otherwise, SAS Tech Support would be a good option to contact.
per Default proc surveylogistic displays an F test in the "testing the null hypothesis /beta = 0 " output. Can I somehow change that to a Chi-Square Test?
Usually I use proc logistics but this time I have a cluster variable and to my knowledge proc logistic cant handle those.
In the documentation I read the F and Chi-Square test are equivallent but I get different results for the significance tests (although the point estimates for intercept and my independent variable are the same) to proc logistic for the same analysis.
I also tried using the df=infinity option but the name just changes the value stays the same.
Regards
I am analyzing a temporal trend(yr) of certain chemicals(a b & c).
I use proc sgplot and series statement to draw a plot and found there was a decreasing trend.
Becuase the data is right-skewed, I used the median concentration of each year to draw the plot.
Now I would like to conduct a statistical test on the trend. My data came from the NHANES and need to use the proc survey** to perform analysis. I know I can do an ANOVA test based on proc surveyreg and use ANOVA option in the MODELstatement.
proc suveyreg data=a;
stratum stra;
cluster clus;
weight wt;
model a=yr/anova;
run;
But since the original data is right-skewed, I think maybe it is better to use Kruskal-Wallis test on the original data. But I don't know how to write a code in SAS and I didn't find information in proc survey**-related document.
My plan B is to use the log-transformed data and ANOVA test. But I am not sure if that is an appropriate approach. Can somebody tell me how to get the normality test of the residual in ANOVA while using proc surveyreg? I would also like to know if I can test a b & c in one procedure or I should write multiple procedures with changes in MODEL statement.
Looking forward to your engagement.Thank you!
I'm running a multivariate linear regression model in SAS (v. 9.3) using the REG procedure with the stepwise statement, as follows below:
(1) Set the regressors list:
%let regressors = x1 x2 x3;
(2) Run the procedure:
ods output DWStatistic=DW ANOVA=F_Fisher parameterestimates=beta CollinDiag=Collinearita outputstatistics=residui fitstatistics=rsquare;
proc reg data=base_dati outest=reg_multivar edf;
model TD&eq. = ®ressors. /selection=stepwise`SLSTAY=&signif_amm_multivar_stay. SLENTRY=&signif_amm_multivar_entry. VIF COLLIN adjrsq DW R influence noint;
output out=diagnostic;
quit;
ods output close;
By adding one regressor to the list, let's say x4, to the macro-variable ®ressors., the beta value estimates change, although the selected variables are the same ones.
In practice, in both cases the variables chosen from such selection method are x1 and x2, but beta parameters for x1 and x2 change in the second case with respect to the second case.
Could you provide an explanation for that?
It would be nice to have a reference for such explanation.
Thanks all in advance!
I'm going to guess that you have missing data. SAS removes records row wise. So if you include 2 more variables that happen to have a few missing those entire records will be missing which means you're not actually using the exact same data between each regression model.
I'm not so familiar with SAS proc glm. All I have done using proc glm so far is to output parameter estimates and predicted values on training datasets. But I also need to use the fitted model to make prediction on testing dataset. (both point estimates and interval estimates)
Here is my code.
ods output ParameterEstimates=Pi_Parameters FitStatistics=Pi_Summary PredictedValues=Pi_Fitted;
proc glm data=Train_Pi;
class Area Fo5 Tye M0 M1 M2 M3;
model Pi = Dow Area Fo5 Tye M0|HC M1|HC M2|HC M3|HC/solution p ss3 /*tolerance*/;
run;
But how to proceed to next step? something like predict(Model_from_Train_Pi,Test_Pi)
If you're on SAS 9.4 see Jake's answer from this question:
How to predict probability in logistic regression in SAS?
If not on 9.4, my answer applies for adding the data in to the original data set.
A third option is PROC SCORE - documentation has an example for proc reg that's almost identical to your question:
http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_score_sect018.htm