一下程序在winbugs中定义矩阵,Problem 1是例子。
Problem 1:
Utility specifications
U1 = a1 + b11*x11+b12*x12+ b21*x21+b22*x22;
U2 = a2;
U3 = 0;
有多少产品和自变量?
prods<-3: 产品是三个 U1 U2 U3
atts2<-4 # 4independent variables : x11 x1 x21 x22
以下程序在定义自变量和Z矩阵。
# Sets Up Independent Variable Matrices (You don’t changethis part)
A2<-c(1:(Obs*atts2))
dim(A2)<-c(Obs,atts2)
# Dummies referencing for which products these areattributes (You don’t change this part)
z<-c(1:(prods*atts2))
dim(z)<-c(prods,atts2)
z<-0*z
# Product Attributes (You change this part)
A2[1:Obs,1]<-(MyData$x11[1:Obs])
A2[1:Obs,2]<-(MyData$x12[1:Obs])
A2[1:Obs,3]<-(MyData$x21[1:Obs])
A2[1:Obs,4]<-(MyData$x22[1:Obs])
# Set Indicator Variables for which products are affiliatedwith each attribute (You change this part)
z[1,1]<-1 # x11
z[1,2]<-1 # x12
z[1,3]<-1 # x21
z[1,4]<-1 # x22
问题是:problem2-problem5如何定义??????????
Problem 2:
Utility specifications
U1 = a1 + b11*x11+b12*x12;
U2 = a2 + b21*x21+b22*x22;
U3 = 0;
How many product choices andindependent variables?
prods<-3
atts2<-4
What is the correct way to set up A2and z?
# Sets Up IndependentVariable Matrices (You don’t change this part)
A2<-c(1:(Obs*atts2))
dim(A2)<-c(Obs,atts2)
# Dummies referencing for which products these areattributes (You don’t change this part)
z<-c(1:(prods*atts2))
dim(z)<-c(prods,atts2)
z<-0*z
# Product Attributes (You change this part)
A2
# Set Indicator Variables for which products are affiliatedwith each attribute (You change this part)
z
Problem 3:
Utility specifications
U1 = a1 + b11*x11+b12*x12 + b31*x3;
U2 = a2 + b21*x21+b22*x22 + b32*x3;
U3 = 0;
How many product choices andindependent variables?
What is the correct way to set up A2and z?
Problem 4:
Utility specifications
U1 = a1 + b11*x11+b12*x12 + b3*x3;
U2 = a2 + b21*x21+b22*x22 + b3*x3;
U3 = 0;
How many product choices andindependent variables?
What is the correct way to set up A2and z?
Problem 5:
Utility specifications
U1 = a1 + b11*x11+b12*x12 + b3*x3;
U2 = a2 + b21*x21+b22*x22 + b3*x3;
U3 = a3 + b3*x3;
U4 = 0;
How many product choices andindependent variables?
What is the correct way to set up A2and z?