FAQ Database Discussion Community

## Multiple regressions with subsets of data using dplyr in R

r,regression,dplyr

## How do you use variables in a regression formula in R?

r,regression
How do you use a variable in a regression formula? For example, using the 'Animals' dataset (in MASS), the following works fine: data(Animals) model <- lm(body ~ brain, data = Animals) But what I want to do is: data(Animals) x <- "body" y <- "brain" model <- lm(x ~ y,...

## R Forecast with lagged dependent variable

r,loops,regression,lag,dummy-data
Use lm function in to fit (Pt=aPt-1 + bXt + Dummy variable for each quarter) to fit the sample data. How to create n.ahead=12 forecast? Couldnt figure out how to set up dummy and Pt-1 fore iteration.Any help is appreciated!

## Regression loop in R for data frames

r,loops,statistics,data.frame,regression
rm(list=ls()) myData <-read.csv(file="C:/Users/Documents/myfile.csv",header=TRUE, sep=",") for(i in names(myData)) { colNum <- grep(i,colnames(myData)) ##asigns a value to each column if(is.numeric(myData[3,colNum])) ##if row 3 is numeric, the entire column is { ##print(nxeData[,i]) fit <- lm(myData[,i] ~ etch_source_Avg, data=myData) #does a regression for each column in my csv file against my independent variable 'etch'...

## How to find algo type(regression,classification) in Caret in R for all algos at once?

r,machine-learning,classification,regression,caret

## Change basic assumptions of “add trendline” in excel

excel,regression,trendline
I'm plotting some interaction effects that stem from a regression in stata. I'm using excel for convenience. The data are curvilinear and I'm adding a polynomial trendline to maximize the fit. The problem I have is that the trendline function seems to assume that the x values are 1, 2,...

## Used Predict function on New Dataset with different Columns

r,regression,predict

## How to rescale “linear predictor” in drawing nomogram with “rms” package in R?

r,regression
I am trying to draw a nomogram from a logistic regression in R by using the rms package, but currently I have a problem: indeed, I can get the nomogram, but the "linear predictor" axis ranges from -2.5 to +3, and I'd like to know whether I can make it...

## R: HAC by NeweyWest using dynlm

r,time-series,regression