regression

Customizing tables in Stata

青春壹個敷衍的年華 提交于 2019-12-25 14:49:57
问题 Using Stata14 on windows, I am wondering how to build customized tables from several regression results. Here is an example. We have reg y, x1 predict resid1, residuals summarize resid1 Which gives: Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- resid1 | 5,708,529 4.83e-11 .7039736 -3.057633 3.256382 And run another regrerssion and similarly obtain the residuals: reg y, x2 predict resid2, residuals I would like to create a table

Customizing tables in Stata

一笑奈何 提交于 2019-12-25 14:49:24
问题 Using Stata14 on windows, I am wondering how to build customized tables from several regression results. Here is an example. We have reg y, x1 predict resid1, residuals summarize resid1 Which gives: Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- resid1 | 5,708,529 4.83e-11 .7039736 -3.057633 3.256382 And run another regrerssion and similarly obtain the residuals: reg y, x2 predict resid2, residuals I would like to create a table

Error on train() function in R [closed]

。_饼干妹妹 提交于 2019-12-25 09:29:04
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I am trying to learn from an online example and got stuck on one part. Particularly when i use train() function. I got an error saying train isn't a function. I did research and believe train is a function. The code i copied was : xgb_tree_model = train(SalePrice~., data=train, method="xgbTree", trControl

How to apply a regression in a for loop for all the variables of a dataset while adding rows in R

自闭症网瘾萝莉.ら 提交于 2019-12-25 08:27:25
问题 That is a long question I know, but bear with me. I have a dataset in this form: head(TRAINSET) X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 Y 1 -2.973012 -2.956570 -2.386837 -0.5861751 4e-04 0.44 0.0728 0.0307 0.0354 0.0078 0.0047 0.0100 -0.0022 0.0038 -0.005200012 2 -2.937649 -2.958624 -2.373960 -0.5636891 5e-04 0.44 0.0718 0.0323 0.0351 0.0075 0.0028 0.0095 -0.0019 0.0000 0.042085781 3 -2.984238 -2.937649 -2.428712 -0.5555258 2e-04 0.43 0.0728 0.0329 0.0347 0.0088 0.0018 0.0092 -0.0019

predict() and newdata - How does this work?

大城市里の小女人 提交于 2019-12-25 07:59:31
问题 Someone recently posted a question on this paper here: https://static.googleusercontent.com/media/www.google.com/en//googleblogs/pdfs/google_predicting_the_present.pdf The R code of the paper can be found at the very end of the paper. Essentially, the paper investigates one-month ahead predictions of sales through search queries. I think I understood the model and method, but there's one detail that puzzles me. It's the part: 1 ##### Divide data by two parts - model fitting & prediction dat1

R: conditional binary logistic regression - Syntax and debugging

时光总嘲笑我的痴心妄想 提交于 2019-12-25 07:29:06
问题 From my talks with experts here (Link1, Link2), I think I need to do a conditional binary logistic regression. I have sorted my data in a way that each control is exactly followed by the counterpart treatment case and the data is in long format. My design is detailed in the above two links plus these two more links: Link3, Link4 edit: later I saw that sorting is not at all important because the sorted and non-sorted data resulted in the same output. My syntax is the following. The code runs

Regression of variables in a dataframe

北慕城南 提交于 2019-12-25 06:44:59
问题 I have a dataframe: df = data.frame(x1 = rnorm(50), x2 = rnorm(50), x3 = rnorm(50), x4 = rnorm(50)) I would like to regress each variable versus all the other variables, for instance: fit1 <- lm(x1 ~ ., data = df) fit2 <- lm(x2 ~ ., data = df) etc. (Of course, the real dataframe has a lot more variables). I tried putting them in a loop, but it didn't work. I also tried using lapply but couldn't produce the desired result either. Does anyone know the trick? 回答1: You can use reformulate to

Output from scatter3d R script - how to read the equation

跟風遠走 提交于 2019-12-25 05:37:58
问题 I am using scatter3d to find a fit in my R script. I did so, and here is the output: Call: lm(formula = y ~ (x + z)^2 + I(x^2) + I(z^2)) Residuals: Min 1Q Median 3Q Max -0.78454 -0.02302 -0.00563 0.01398 0.47846 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.051975 0.003945 -13.173 < 2e-16 *** x 0.224564 0.023059 9.739 < 2e-16 *** z 0.356314 0.021782 16.358 < 2e-16 *** I(x^2) -0.340781 0.044835 -7.601 3.46e-14 *** I(z^2) 0.610344 0.028421 21.475 < 2e-16 *** x:z -0.454826 0

Regression of a Data Frame with multiple factor groupings

烂漫一生 提交于 2019-12-25 05:32:00
问题 I am working on a regression script. I have a data.frame with roughly 130 columns, of which I need to do a regression for one column (lets call it X column) against all the other ~100 numeric columns. Before the regression is calculated, I need to group the data by 4 factors: myDat$Recipe , myDat$Step , myDat$Stage , and myDat$Prod while still keeping the other ~100 columns and row data attached for the regression. Then I need to do a regression of each column ~ X column and print out the R^2

How to write interactions in regressions in R?

心不动则不痛 提交于 2019-12-25 05:00:20
问题 DF <- data.frame(factor1=rep(1:4,1000), factor2 = rep(1:4,each=1000),base = rnorm(4000,0,1),dep=rnorm(4000,400,5)) DF$f1_1 = DF$factor1 == 1 DF$f1_2 = DF$factor1 == 2 DF$f1_3 = DF$factor1 == 3 DF$f1_4 = DF$factor1 == 4 DF$f2_1 = DF$factor2 == 1 DF$f2_2 = DF$factor2 == 2 DF$f2_3 = DF$factor2 == 3 DF$f2_4 = DF$factor2 == 4 I want to run the following regression: Dep = (f1_1 + f1_2 + f1_3 + f1_4)*(f2_1 + f2_2 + f2_3 + f2_4)*(base+base^2+base^3+base^4+base^5) Is there a smarter way to do it? 回答1: