! Social Homogamy Model
! Fear of social criticism in US twins
!
! Two scripts, first the way it is in the book, which is wrong
! Second, a way with another constraint on the variance of C in the
! offspring generation, per Matt McGue Jan 18 suggestion.
!
G1: Model parameters
Data Calculation NGroups=4
Begin Matrices;
D Full 1 1 free    ! assortative mating paths
C Low  1 1 free    ! common environment paths
A Low  1 1 free    ! additive genetic paths
F Full 1 1 free    ! paternal cultural transmission
M Full 1 1 free    ! maternal cultural transmission
G Symm 1 1         ! additive genetic covariance (Ra)
R Symm 1 1 free    ! common environment covariance (Rc)
J Low  1 1 free    ! specific environment paths
H Full 1 1         ! scalar, .5
P Full 1 1 free
End Matrices;
Matrix H .5
Matrix G .5
Start .3 All
Begin Algebra;
W= C*D*C' ;                       ! Mother-Father Covariance
O= (C*F'+ C*D*M')*C'+ A*H*A' ;    ! Father-Child Covariance
Q= (C*M'+ C*D*F')*C'+ A*H*A' ;    ! Mother-Child Covariance
U=  A*G*A'+ C*R*C' ;              ! MZ Twin Covariance
V=  H@A*G*A'+ C*R*C' ;            ! DZ Twin Covariance
End Algebra;
End

G2: Model constraints
Data Constraint NInput=1
Matrices= Group 1
Constraint P- (A*G*A'+ C*R*C'+ J*J') / ! Phenotypic Variance
Bound 0 1 D 1 1 1
Option RSidual
End

G3 - MZ Twins and parents  
DA NInput=4 NObservations=144
Labels MZ1 MZ2 Mother Father 
Cmatrix File=rofemzpo.cov
Select Father Mother MZ1 MZ2
Matrices= Group 1
Covariance ( P | W'| O | O )_
           ( W | P | Q | Q )_
           ( O'| Q'| P | U )_
           ( O'| Q'| U'| P )   /
Option RSidual
End

G4 - DZ twins and parents  
Data NInput=4 NObservations=106
Labels DZ1 DZ2 Mother Father 
Cmatrix File=rofedzpo.cov
Select Father Mother DZ1 DZ2
Matrices= Group 1
Covariance ( P | W'| O | O )_
           ( W | P | Q | Q )_
           ( O'| Q'| P | V )_
           ( O'| Q'| V'| P )   /
Option RSidual Iterations=800
End

! Social Homogamy Model
! Fear of social criticism in US twins

G1: Model parameters
Data Calculation NGroups=4
Begin Matrices;
D Full 1 1 free    ! assortative mating paths
C Low  1 1 free    ! common environment paths
A Low  1 1 free    ! additive genetic paths
F Full 1 1 free    ! paternal cultural transmission
M Full 1 1 free    ! maternal cultural transmission
G Symm 1 1         ! additive genetic covariance (Ra)
R Symm 1 1 free    ! common environment covariance (Rc)
J Low  1 1 free    ! specific environment paths
H Full 1 1         ! scalar, .5
P Full 1 1 free
End Matrices;
Matrix H .5
Matrix G .5
Start .3 All
Begin Algebra;
W= C*D*C' ;                       ! Mother-Father Covariance
O= (C*F'+ C*D*M')*C'+ A*H*A' ;    ! Father-Child Covariance
Q= (C*M'+ C*D*F')*C'+ A*H*A' ;    ! Mother-Child Covariance
U=  A*G*A'+ C*R*C' ;              ! MZ Twin Covariance
V=  H@A*G*A'+ C*R*C' ;            ! DZ Twin Covariance
End Algebra;
End

G2: Model constraints
Data Constraint NInput=1
Begin Matrices= Group 1
 I unit 1 1
 T full 1 1
End Matrices;
 Matrix T 2
Constraint  (P - (A*G*A'+ C*R*C'+ J*J') )        _  ! Phenotypic Variance
                  ( I - M*M+F*F - T*(M*F*D) - R)    ;   ! Variance of C =
1 
Bound 0 1 D 1 1 1
Option RSidual
End

G3 - MZ Twins and parents  
DA NInput=4 NObservations=144
Labels MZ1 MZ2 Mother Father 
Cmatrix File=rofemzpo.cov
Select Father Mother MZ1 MZ2
Matrices= Group 1
Covariance ( P | W'| O | O )_
                   ( W | P | Q | Q )_
                   ( O'| Q'| P | U )_
                   ( O'| Q'| U'| P )   /
Option RSidual
End

G4 - DZ twins and parents  
Data NInput=4 NObservations=106
Labels DZ1 DZ2 Mother Father 
Cmatrix File=rofedzpo.cov
Select Father Mother DZ1 DZ2
Matrices= Group 1
Covariance ( P | W'| O | O )_
           ( W | P | Q | Q )_
           ( O'| Q'| P | V )_
           ( O'| Q'| V'| P )   /
Option Check
Option RSidual Iterations=800
End

