[R] Running multidimensional regressions
David Winsemius
dwinsemius at comcast.net
Tue Jan 14 06:51:14 CET 2014
On Jan 13, 2014, at 4:28 PM, andrews Nikolaiv wrote:
>
>
>
> Dear R helpers!,
>
> I have a question on how to run a regression with many indices.
> To give you a practical example,
>
> let
> y_{itabp} be an dependent variable (representing prices) indexed by
> i=country, t=time, a=area, b=brand and p=package size.
>
> In
> particular, we collected prices on the product "cereals" from i=1...,I countries
> over a period of t=1,...,T_{i} months. For example, for Italy we have
> price information over24 months whereas for Germany we have price
> information over 36 months.
> For each country, we have price
> information by area (a=1,...,A_{i}- for example, for Italy we have
> price information for 5 areas whereas for Germany we have price
> information for 9 areas).
> For each area we have information on prices by brand (b=1,...,4 )
> Finally, for each brand prices are broken down by package size (p=1,2,3)
>
> I want to run a semiparametric regression to see the effect of package size on y_{itcabp}
> I display a sample of my data
>
>
>
>
>
>
> Country
> Area
> brand
> packsize
> dates
> price
> Package_size
>
>
> AA
> A1
> b1
> ps1
> 01/11/2008
> 1.760342
> 0.075
>
>
> AA
> A1
> b1
> ps1
> 01/12/2008
> 1.786739
> 0.075
>
>
> AA
> A1
> b1
> ps2
> 01/11/2008
> 1.725466
> 0.075
>
>
> AA
> A1
> b1
> ps2
> 01/12/2008
> 1.678327
> 0.075
>
>
> AA
> A1
> b1
> ps3
> 01/11/2008
> 1.941369
> 0.075
>
>
> AA
> A1
> b1
> ps3
> 01/12/2008
> 1.874848
> 0.075
>
>
> AA
> A2
> b2
> ps1
> 01/11/2008
> 21.49573
> 0.075
>
>
> AA
> A2
> b2
> ps1
> 01/12/2008
> 22.40766
> 0.075
>
>
> AA
> A2
> b2
> ps2
> 01/11/2008
> 23.44514
> 0.075
>
>
> AA
> A2
> b2
> ps2
> 01/12/2008
> 23.1251
> 0.075
>
>
> AA
> A2
> b2
> ps3
> 01/11/2008
> 22.14254
> 0.075
>
>
> AA
> A2
> b2
> ps3
> 01/12/2008
> 21.04197
> 0.075
>
>
> BB
> A1
> b1
> ps1
> 01/01/2009
> 17.38787
> 0.05
>
>
> BB
> A1
> b1
> ps1
> 01/02/2009
> 18.45013
> 0.05
>
>
> BB
> A1
> b1
> ps2
> 01/01/2009
> 17.59772
> 0.05
>
>
> BB
> A1
> b1
> ps2
> 01/02/2009
> 18.41634
> 0.05
>
>
> BB
> A1
> b1
> ps3
> 01/01/2009
> 18.55188
> 0.05
>
>
> BB
> A1
> b1
> ps3
> 01/02/2009
> 19.08645
> 0.05
>
>
> I also created the variables
>
> countryN that takes 1 for AA, 2 for BB etc,
> AreaN that takes 1 for A1, 2 for A2, etc,
> brandN that takes 1 for b1, 2 for b2 etc,
> packsizeN that takes 1 for ps1, 2 for ps2 etc,
> timeN that takes 1 for 01/11/2008 or 01/01/2009 and 2 for 01/12/2008 or 01/02/2009
> I, then, run
>
> data<- read.csv("cereals.csv")
> rm(list=ls())
Wouldn't that destroy all your work to read from "cereals.csv"?
> foo <- read.csv("cereals.csv")
> attach(foo)
> require(np)
> model <- npreg(price~factor(Package_size)+factor(timeN)+factor(countryN)+factor(AreaN)+ordered(brandN)+ordered(packsizeN))
> summary(model)
> plot(model,common.scale=FALSE)
>
>
> Do you think that these commands serve my goal (to estimate the effect of package size on y_{itcabp})?
>
> Any code provided is greatly appreciated.
>
> Thank you very much in advance,
>
> andrews
>
>
>
> [[alternative HTML version deleted]]
You should post in plain text.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list