请教一下各位大佬
如何将如下的函数在R语言中写出来,我用stata写了一个例子:
----------------------- copy starting from the next line -----------------------
gen double `f1'=normalden($ML_y1,`xb1',exp(`lns1'))
gen double `f2'=normalden($ML_y1,`xb2',exp(`lns2'))
tempvar p
gen double `p'=exp(`lp')/(1+exp(`lp'))
replace `f'=`p'*`f1'+(1-`p')*`f2'
------------------ copy up to and including the previous line ------------------
函数如下,是一个由两个ols组成的混合模型,表达式如下:
$$f(y_{it}| x_{it})=\frac{\pi }{\sigma _{1}}\times \phi (\frac{y_{it}-x_{it}\beta _{1}}{\sigma _{1}})+\frac{1-\pi }{\sigma _{2}}\times \phi (\frac{y_{it}-x_{it}\beta _{2}}{\sigma _{2}})$$