Displaying 20 results from an estimated 40000 matches similar to: "for loop and linear models"
2011 Nov 26
2
simplify source code
Hi
I would like to shorten
mod1 <- nls(ColName2 ~ ColName1, data = table, ...)
mod2 <- nls(ColName3 ~ ColName1, data = table, ...)
mod3 <- nls(ColName4 ~ ColName1, data = table, ...)
...
is there something like
cols = c(ColName2,ColName3,ColName4,...)
for i in ...
mod[i-1] <- nls(ColName[i] ~ ColName1, data = table, ...)
I am looking forward to help
Christof
2011 Jan 21
2
Looping with incremented object name and increment function
Folks,
I am trying to get a loop to run which increments the object name as part of
the loop. Here "fit1" "fit2" "fit3" and "fit4" are linear regression models
that I have created.
> for (ii in c(1:4)){
+ SSE[ii]=rbind(anova(fit[ii])$"Sum Sq")
+ dfe[ii]=rbind(summary(fit[ii])$df)
+ }
Error in anova(fit[ii]) : object 'fit' not found
2011 Jul 07
3
coefficients lm of data.frame
Hi,
I've a data frame like this:
> as.data.frame(cbind(rnorm(1:12),rnorm(1:12)))
V1 V2
1 -1.30849402 -0.52094136
2 0.96157302 0.76217871
3 -0.44223351 -1.72630871
4 -0.10432438 -1.04732942
5 -1.38748914 0.95877311
6 -0.63965975 0.65494811
7 -0.24058318 0.19496830
8 -0.11172988 1.01680655
9 0.08065333 0.22168589
10 0.25196536 0.84619914
11
2011 Aug 23
3
Linear Regression with 2 grouping variables
Hi all,
I have a data set that looks a bit like this.
feed1
RFU Site Vial Time lnRFU
1 44448 1 1 10 10.702075
2 47521 1 1 20 10.768927
3 42905 1 1 30 10.66674
4 46867 1 1 40 10.755069
5 42995 1 1 50 10.668839
6 43074 1 1 60 10.670675
7 41195 1 1 70 10.626072
8 47090 1 2 10 10.759816
9 48100 1
2011 May 23
6
Reading Data from mle into excel?
Hi there,
I ran the following code:
vols=read.csv(file="C:/Documents and Settings/Hugh/My Documents/PhD/Swaption
vols.csv"
, header=TRUE, sep=",")
X<-ts(vols[,2])
#X
dcOU<-function(x,t,x0,theta,log=FALSE){
Ex<-theta[1]/theta[2]+(x0-theta[1]/theta[2])*exp(-theta[2]*t)
Vx<-theta[3]^2*(1-exp(-2*theta[2]*t))/(2*theta[2])
dnorm(x,mean=Ex,sd=sqrt(Vx),log=log)
}
2011 Jan 07
2
how to run linear regression models at once
hey, folks,
I have two very simple questions. I am not quite sure if I can do this using
R.
so, I am analyzing a large data frame with thousands of variables. For
example:
Dependent variables: d1, d2, d3 (i.e., there are three dependent variables)
Independent variables: s1, s2, s3, ......s1000 (i.e., there are 1000
independent variables)
now I want to run simple linear regression analyses of
2011 Oct 14
3
Split a list
I have a list of dataframes i.e. each list element is a dataframe with three columns and differing number of rows. The third column takes on only two values. I wish to split the list into two sublists based on the value of the third column of the list element.
Second issue with lists as well. I would like to reduce each of the sublist based on the range of the second column, i.e. if the range of
2011 Jun 27
2
Executing the same function on consecutive files
Hi all,
I have the next problem: I have a matrix with size 8,000,000x18. My personal
computer...blocks...so I have cut my original file into 100 different file.
I have written a function that should be run on each of this file.
So imagine
I need to read data from q1 to q100 file
data<-read.table("q1.txt",sep="")
and each time I read 1 file execute my personal function
2012 Dec 05
4
Import multiple data frames and combine them using "cbind"
Hi group,
I imported 16 data frames using the function "list.files"
temp <- list.files(path="...........")
myfiles = lapply(temp, read.table,sep = "")
Now I have 16 data set imported in R window.
I want to combine them by row and tried some thing like (Here I am
considering only 20 columns)
for(i in 1:16){
data<- cbind(myfiles[[i]][,1:20])
}
but it
2011 Jun 30
2
Saving fExtremes estimates and k-block return level with confidence intervals.
I am estimating a large model by groups. How do you save the results and?returns
the associated quantiles?
For this example I need a data frame
n?? ?xi??????? mu????????beta
1?? 0.1033614? 2.5389580 0.9092611
2? ?0.3401922? 0.5192882 1.5290615
3?? 0.5130798? 0.5668308 1.2105666
I also want to apply gevrlevelPlot() for each "n" or group.
?
#Example
n <- c(1, 1, 1, 1, 1, 1, 2, 2, 2,
2011 Jan 17
2
Summing data frame columns on identical data
Dear all,
I have 9 data frames, and I'm simply trying to sum the values of column 3 (on a row-by-row basis). However, there are a slightly different number of rows in each data frame, so I'm receiving the following error: "Error in Ops.data.frame(mrunoff_207101[3], mrunoff_207102[3]) :
? + only defined for equally-sized data frames".
Here is what I'm attempting to do:
2010 Dec 29
5
linear regression for grouped data
Hi,
I have been examining large data and need to do simple linear regression
with the data which is grouped based on the values of a particular
attribute. For instance, consider three columns : ID, x, y, and I need to
regress x on y for each distinct value of ID. Specifically, for the set of
data corresponding to each of the 4 values of ID (76,111,121,168) in the
below data, I should invoke
2011 Sep 29
3
For loop for subset - repeating same over and over?
Hello, I am using the following script to run an anova for numerous species
in a table that I have:
SiteSpp <-
2011 Feb 08
1
Grouping by factors in R
I'm having a hard time figuring out how to group results by certain
factors in R. I have data with the following headings:
[1] "Time" "Plot" "LatCat" "Elevation" "ElevCat"
"Aspect" "AspCat" "Slope"
[9] "SlopeCat" "Species" "SizeClass" "Stems"
and
2011 Aug 04
3
functions on rows or columns of two (or more) arrays
I realize this should be simple, but even after reading over the several
help pages several times, I still cannot decide between the myriad "apply"
functions to address it. I simply want to apply a function to all the rows
(or columns) of the same index from two (or more) identically sized arrays
(or data frames).
For example:
> a=matrix(1:50,nrow=10)
>
2011 May 23
2
Linear regression - several response variables vs few ind variables
Hi all,
I need to run several simple linear regressions at once, using the
following data. Response variables: Bird species (sp 1, sp2, sp3...spn).
Independent variable: Natprop - proportion of natural area. covarate:
Effort = hours). One single linear regression would be: lmSp1 <- lm(sp1~
natprop + effort). However, I need to run this linear regression for all
bird species that I have
2006 Jan 29
2
SoS! How to predict new values using linear regression models?
Hi all,
After trial and error by myself for a few hours, I decide to ask for your
help.
I have a training set which is a matrix of size 200 x 2, where the two
columns denote each independent variable. I have 200 observations.
-----------------
ss=data.frame(trainingSet);
result=lm(trainingClass~ss$X1+ss$X2);
-----------------
where trainingClass denotes the true classes of the training data.
2006 May 15
3
Dyn or Dynlm and out of sample forecasts
All:
How do I obtain one step ahead out-of-sample forecasts from a model
using "dyn" or "dynlm" ?
Thanks!
Best,
John
[[alternative HTML version deleted]]
2011 Jun 10
4
Linear multivariate regression with Robust error
Dear all,
i am doing linear regression with robust error to know the effect of
a (x) variable on (y)other if i execute the command i found positive
trend.
But if i check the effect of number of (x.x1,x2,x3)variables
on same (y)variable then the positive effect shwon by x variable turns
to negative. so plz help me in this situation.
Barjesh Kochar
Research scholar
2008 Oct 15
2
dynlm and lm: should they give same estimates?
Hi,
I was wondering why the results from lm and dynlm are not the same for what I think is the same model.
I have just modified example 4.2 from the Pfaff book, please see below for the code and results.
Can anyone tell my what I am doing wrongly?
Many thanks,
Werner
set.seed(123456)
e1 <- rnorm(100)
e2 <- rnorm(100)
y1 <- ts(cumsum(e1))
y2 <- ts(0.6*y1 + e2)
lr.reg <- lm(y2