Closed FreezingGod closed 11 years ago
I am not entirely sure where in that tutorial-BST.R it went wrong. But that code include many examples so it is not a good place to start with. Please follow: https://github.com/beechung/Latent-Factor-Models/blob/master/doc/tutorial.pdf
for tutorial.
Thanks, Liang
On Thu, Jun 20, 2013 at 9:31 PM, Zachary Ling notifications@github.comwrote:
The tutorial-BST.R gives the following error:
source("src/R/examples/tutorial-BST.R"); Loading required package: lattice
WARNING: You did not specify the following components in factor: gamma
WARNING: You did not specify the following components in param: h0, var_gamma
================= START fit.MCEM ===================================== Initial loglik: CD = -19358.42494, E = NA (0.00 sec)
test loss: 6.148298 (0.007 sec) write a model & summary info on to disk (used 0.003 sec)
Iteration 1
start E-STEP Error in MCEM_EStep.multicontext.C(factor = factor, obs = obs, feature = feature, : invalid mode (NULL) to pass to C or Fortran (arg 3) In addition: Warning messages: 1: You did not specify the following components in factor: gamma
2: You did not specify the following components in param: h0, var_gamma
I am using R version 3.0.1 (2013-05-16) -- "Good Sport" and the C, FORTRAN code compiles without any warning message. What is the possible reason for this error? Thanks.
— Reply to this email directly or view it on GitHubhttps://github.com/beechung/Latent-Factor-Models/issues/7 .
Hi Liang, Thanks for the comments. I have tried following the tutorial and got exactly the same error. It seems that the R version 2.15.0 changed the behavior of .C() when passing a NULL pointer. Please refer to https://stat.ethz.ch/pipermail/r-devel/2012-May/064201.html for more details.
As far as I can see (I am very new to R and I could be wrong), the problem of the error is caused by trying to pass the NULL directly to the external C function MCEM_EStep_multicontext as is defined in factor_model_multicontext.c. In the example code and the tutorial, the gamma is set to NULL and passed to this function. However, in recent version of R (3.0.1, I haven't tried old versions of R), you are not allowed to pass NULL argument directly in .C().
To get rid off the error, I added as.double() or as.integer() wrapper for all the parameters that is NULL in the .C() calling code. I am not familiar with R and not sure if this really solves the problem. But the tutorial code can run successfully after the change.
Thanks, Zachary
Hi, Zachary I also come with the same problem with you. But after I add as.double/integer to the parameters called by .C() , the problem still exist. Would you please tell me where in the code (which file which line of the code)you added the as.double/integer?
Many Thanks.
Xin
Hi, I am also getting the same problem.
ans = fit.bst(obs.train=obs.train, obs.test=obs.test,
WARNING: You did not specify the following components in factor: gamma
WARNING: You did not specify the following components in param: h0, var_gamma
================= START fit.MCEM =====================================
Initial loglik: CD = -19358.42494, E = NA (0.01 sec)
test loss: 6.148298 (0.01 sec)
Iteration 1
start E-STEP Error in MCEM_EStep.multicontext.C(factor = factor, obs = obs, feature = feature, : invalid mode (NULL) to pass to C or Fortran (arg 3) In addition: Warning messages: 1: You did not specify the following components in factor: gamma 2: You did not specify the following components in param: h0, var_gamma
I guess the problem is because of the null parameter values only . I am using R 3.0.2. Please help if there is any information regarding this.
As stated by FreezingGod changing the .C call in the MCEM_EStep.multicontext.C function to following allows this to run.
ans = .C("MCEM_EStep_multicontext",
factor$alpha,
factor$beta,
as.double(factor$gamma),
factor$u,
factor$v,
factor$w,
# OUTPUT
factor$alpha_global,
factor$beta_global,
factor$fScore,
sampvar$fScore,
sampvar$alpha,
sampvar$alpha_global,
sampcov$alpha,
sampvar$beta,
sampvar$beta_global,
sampcov$beta,
as.double(sampvar$gamma),
sampvar$u,
sampvar$v,
sampvar$w,
as.double(test.fScore$mean),
as.double(test.fScore$var),
# INPUT
as.integer(nSamples),
as.integer(nBurnIn),
obs$src.id,
obs$dst.id,
obs$src.context,
obs$dst.context,
obs$edge.context,
param[["q"]],
param[["r"]],
obs.y,
x_src.g0,
x_dst.d0,
as.double(x_ctx.h0),
x_src.G,
x_dst.D,
x_ctx.H,
param$var_y,
param$var_alpha,
param$var_alpha_global,
param$var_beta,
param$var_beta_global,
as.double(param$var_gamma),
param$var_u,
param$var_v,
var_w,
as.integer(test.obs$src.id),
as.integer(test.obs$dst.id),
as.integer(test.obs$src.context),
as.integer(test.obs$dst.context),
as.integer(test.obs$edge.context),
dim,
length(dim),
# OTHER
debug,
verbose,
DUP = FALSE
)
The tutorial-BST.R gives the following error:
I am using R version 3.0.1 (2013-05-16) -- "Good Sport" and the C, FORTRAN code compiles without any warning message. What are the possible reasons for this error? Thanks.