At the beginning: I am very 'fresh' user of R so excuse me all my mistakes and silly questions.
I would like to estimate 570 (30*19) equations (and get summary() of them). Each equation is in the form: y~x2+x3+x4, where x2, x3 and x4 are the list.
In comment #1 is my failed trial - it can show what i want to achieve.
In comment #2 such equation is working but I need to manually change variable "jan" (to feb, mar, and so on) that should be taken from list "x2". This code return me 30 equations but I need to estimate each of them with one more variable - x2 from the list of 19's elements named "x2"
How to do it automatically ? I mean:
mapply - applies the rlm model to each of the element of the lists so, e.g:
element 1 from list "y" is corresponding with element 1 from "x3" and element 1 from "x4" (I took care about the order when I was preparing csv file) - this is correct but I would like to run such equations like below comment #2 with additional variable x2. This variable is not corresponding any other variables - it always should be in each of the 30 regressions of elements of list "y", just changing from element 1 of list "x2" to element 19 of "x2".
In the end I would like to have 570 (30*19) "summ" matrix and 570 "archtest"
I do hope this is not to muddled, if yes I will try to post it again in some time with clarification.
Thank you kindly for understanding and help.
data<-read.table("MAY EFFECT Rdata 18.09.2013-3 ind prod CCI.csv", head=T, sep=";", dec=".")
library(MASS)
library(FinTS)
index1<-data[,2:31] # y 30 elements; rates, 30 countries
index2<-data[,32:50] # x2 19 elements; month dummies, months and other
index3<-data[,51:80] # x3 30 elements; IP
index4<-data[,81:110] # x4 30 elements; CCI
y<-as.list(index1)
x2<-as.list(index2)
x3<-as.list(index3)
x4<-as.list(index4)
#1. this is my trial I need to make "x2" variable that stands for month dummy be respectively equal jan, feb ... and so on till
# the end of list x2 (19 elements)
result<-mapply(function(x2) mapply(function(y,x3,x4,x2) summary(rlm(y~x2+x3+x4, maxit = 15600, data=data)), y,x3,x4),x2)
#2. this code below is returning 10x30 list matrix "summ" and 5x30 data frame "archtest"
summ<- mapply(function(y,x3,x4,jan) summary(rlm(y~jan+x3+x4, maxit = 15600, data=data)), y,x3,x4)
archtest<-mapply(function (y,x3,x4,jan,resi) {regr<-rlm(y~jan+x3+x4, maxit = 15600, data=data)
ArchTest (resid(regr), lags=12, demean = FALSE)},y,x3,x4)
####