[R] beginner help: 10th index is being overwritten by 11th

2013-11-30 Thread Loyack, Eric
I am using R Studio and writing code to determine p-values for statistical t-tests. Code is below. When I print out the values in the loop for PTMpvalMeans they are correct, but when I store them the 10th one overwrites the 11th. Can someone tell me what I am doing wrong? Thanks in advance, Eric

[R] Latent Heteroskedasticity

2013-11-30 Thread Chiao-Lun Cheng
What is the best package for fitting a model where both the mean and the variance are latent variables? I'm trying to model skew that arises from correlation, i.e., a positive correlation between mean and variance causes positive skew. For example, m ~ a_m + b_m . x + e_m s ~ a_s + b_s . x + e_s

Re: [R] beginner help: 10th index is being overwritten by 11th

2013-11-30 Thread Berend Hasselman
On 30-11-2013, at 08:37, Loyack, Eric wrote: > I am using R Studio and writing code to determine p-values for statistical > t-tests. Code is below. When I print out the values in the loop for > PTMpvalMeans they are correct, but when I store them the 10th one > overwrites the 11th. Can someon

Re: [R] beginner help: 10th index is being overwritten by 11th

2013-11-30 Thread Duncan Murdoch
On 13-11-30 4:37 PM, Loyack, Eric wrote: I am using R Studio and writing code to determine p-values for statistical t-tests. Code is below. When I print out the values in the loop for PTMpvalMeans they are correct, but when I store them the 10th one overwrites the 11th. Can someone tell me wha

Re: [R] mat2listw function

2013-11-30 Thread Jim Lemon
On 11/30/2013 07:05 AM, Jacquelyn Pless wrote: Hi all, I am attempting to create a weights object and perform a Moran I test as well. I have a very large spatial weights matrix (roughly 22,000x22,000) that was created in Excel and read into R, and I'm now trying to implement: library(spdep) SW=

[R] Solve PDE with initial and boundary conditions in R

2013-11-30 Thread Tom O'Brien
Hi,I am trying to port the Matlab code in the link below to R: http://en.literateprograms.org/Asian_Option_Pricing_(MATLAB)This code solves a PDE with initial and boundary conditions.Could anyone point me in the right direction in terms of what packages I should use ?Best Regards,Tom

[R] Calculate Adjusted vcov Matrix acc. to Shanken(1992) (Generated Regressor Problem)

2013-11-30 Thread Philipp Grueber
Dear R Users, I wish to estimate a regression: y=a+b x1+c x2+d x3+e where a is the constant, b,c,d are coefficients and e represents the residuals. However, I find x1 and x2 to correlate. In order to avoid multicollinearity, I split up the estimation: (1) x2~a1+ b1 x1 + e1 (2) y=a2+b2 x1+ c2 e1+

Re: [R] Solve PDE with initial and boundary conditions in R

2013-11-30 Thread Berend Hasselman
On 30-11-2013, at 11:42, Tom O'Brien wrote: > Hi,I am trying to port the Matlab code in the link below to R: > http://en.literateprograms.org/Asian_Option_Pricing_(MATLAB)This code solves > a PDE with initial and boundary conditions.Could anyone point me in the right > direction in terms of w

Re: [R] Multiple regressions with changing dependent variable and time span

2013-11-30 Thread nooldor
Hi, Thanks for reply! Three things: 1. I did not write that some of the data has more then 31 NA in the column and then it is not possible to run lm() Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases In this case program should return "NA" symbol and go

Re: [R] mat2listw function

2013-11-30 Thread David Winsemius
On Nov 30, 2013, at 1:43 AM, Jim Lemon wrote: > On 11/30/2013 07:05 AM, Jacquelyn Pless wrote: >> Hi all, >> >> I am attempting to create a weights object and perform a Moran I test as >> well. I have a very large spatial weights matrix (roughly 22,000x22,000) >> that was created in Excel and re

Re: [R] Multiple regressions with changing dependent variable and time span

2013-11-30 Thread arun
Hi, #1 & 2: set.seed(432) dat1 <- as.data.frame(matrix(sample(c(1:60,NA),154*337,replace=TRUE),ncol=337))  colnames(dat1) <- c(paste("F",1:3,sep="."),paste("r",1:334,sep=".")) lst1 <- lapply(paste("r",1:334,sep="."),function(x) cbind(dat1[,c(1:3)],dat1[x]))  lst2 <- lapply(lst1,function(x) {

Re: [R] Multiple regressions with changing dependent variable and time span

2013-11-30 Thread arun
Hi, I was able to read the file after saving it as .csv.  It seems to work without any errors. dat1<-read.csv("Book2.csv", header=T) ###same as previous lst1 <- lapply(paste("r",1:334,sep="."),function(x) cbind(dat1[,c(1:3)],dat1[x])) lst2 <- lapply(lst1,function(x) {colnames(x)[4] <-"r";x} )

Re: [R] Multiple regressions with changing dependent variable and time span

2013-11-30 Thread nooldor
Hey! Yes, only the D-W test takes so much time, did not check it yet I checked results (estimates) with manually run regressions (in excel) and they are correct. I only change the "width" to 31 and "each=123" to 124, cause it should be ((154-31)+1) x 334 = 41416 matrix with the lag in D-W test I

[R] MOOC on Statistical Learning with R

2013-11-30 Thread Trevor Hastie
Rob Tibshirani and I are offering a MOOC in January on Statistical Learning. This “massive open online course" is free, and is based entirely on our new book “An Introduction to Statistical Learning with Applications in R” (James, Witten, Hastie, Tibshirani 2013, Springer). http://www-bcf.usc.edu

Re: [R] Multiple regressions with changing dependent variable and time span

2013-11-30 Thread arun
Hi, No problem. In that case, each column will be a list.  For example if I take the first element of `lst2` dW1 <- rollapply(lst2[[1]],width=32,FUN=function(z) {z1 <- as.data.frame(z); if(!sum(!!rowSums(is.na(z1 {l1 <-lm(r~F.1+F.2+F.3,data=z1); durbinWatsonTest(l1,max.lag=3) } else rep(NA,

[R] How to get the proportions of data with respect to two variables in R?

2013-11-30 Thread umair durrani
I have 4 columns: Vehicle ID, Vehicle Class, Vehicle Length and Vehicle Width. Every vehicle has a unique vehicle ID (e.g. 2, 4, 5,...) and the data was collected every 0.1 seconds which means that vehicle IDs are repeated in Vehicle ID column for the number of times they were observed. There ar

Re: [R] Problems dealing with matrices

2013-11-30 Thread halim10-fes
Hi Arun, Thank you very much for your kind response. Sorry for my delayed response. Your solutions for the first two questions are quite good for my purpose. Since nobody responded, can you please have a look at the 3rd question? It'll be my great help, if you can give me suggestions. Regards,

Re: [R] How to get the proportions of data with respect to two variables in R?

2013-11-30 Thread Bert Gunter
1. A nice example of why posting a small reproducible example would help get you a useful reply. Your wordy description may not suffice. 2. You are requested not to post in HTML. This is a mailing list, not a web application. 3. table(class$'Vehicle width') is not a function; it is a table object

Re: [R] How to get the proportions of data with respect to two variables in R?

2013-11-30 Thread arun
Hi, It is better to provide a reproducible example. May be this helps: set.seed(252) dat1 <- data.frame(`Vehicle ID`=sample(150,150,replace=FALSE),`Vehicle Class`=rep(1:4,c(20,40,30,60)), `Vehicle length`= sample(15:25,150,replace=TRUE), `Vehicle width`= sample(4:10,150,replace=TRUE),check.names