Error in MCMCglmm: Missing Values in the Fixed Predictors - But I have no missing values - missing-data

I am trying to run the following code -
mod1 <- MCMCglmm(y ~ a + b + c + d + e + f, random =~ g + h + n, data=dat1, verbose = FALSE)
When I run it in R, I get the error message "missing values in the fixed predictors". I do have some missing values in 2 of my independent variables, however, I have used the na.omit() function to omit these rows. I am not sure why I am getting this error message or how to move forward - any help would be greatly appreciated!
This is my first time posting on stack overflow and am happy to provide additional info that may be needed to solve this problem.

Related

Vegan package. db-RDA graph showed only the first 5 variables of the 20 total

I would like to see if the distribution of my species is affected by specific environmental parameters. When I try to do the analysis with the function "capscale ()" the graph showed only the first 5 variables of the 20 total. Please, can someone help me? Thanks.
This is the code I used.
species <- read.table('db-RDA.txt', sep ='\t', h = T, strip.white = T)
species = species[,2:ncol(species)]
species001= (species + 0.001)
fix(species001)
env <- read.table('Env Db-RDA.txt', sep ='\t', h = T, strip.white = T)
env = env[,-1]
env001= (env + 0.001)
fix(env001)
#I have not put all variables but only appeared the first 5 explanatory variables
dbRDA = capscale(species001 ~ Rock + Sand + Rubble + pH + NOx + NH4 + Temp + SIOH + DIC, data=env001, dist = "bray", scale=TRUE)
plot(dbRDA)
I guess that the function told you that some of your variables were aliased. Aliasing means that these variables are linear combinations of some other variables in the model, and there is no independent information to estimate those. See what the output says when you just call the short description of your result. You can get this by typing the name of the result as dbRDA.

OCaml Syntax Error fixed by double semicolon

I'm sorry for asking such a basic question here, but I'm getting a syntax error when trying to compile the following code,
let sum_of_squares_of_two_largest x y z =
let a :: b :: _ = List.sort (fun x y -> -(compare x y)) [x; y; z] in
a * a + b * b;
let rec factorial n =
if n = 0 then 1 else n * factorial (n - 1);
let e_term n = 1.0 /. float_of_int (factorial n);
let rec e_approximation n =
if n = 0 then (e_term 0) else (e_term n) +. (e_approximation (n - 1));
let rec is_even x = if x = 0 then true else is_odd (x - 1);
and is_odd x = not (is_even x);
let rec f_rec n =
if n < 3 then n else f_rec(n - 1) + 2 * f_rec(n - 2) + 3 * f_rec(n - 3);
The uninformative compiler tells me there is syntax error on line 19, which is the last line of the file.
File "source.ml", line 19, characters 0-0:
Error: Syntax error
That is, line 19 is a blank line, only with a new-line character.
I can "fix" this syntax error by adding ;; at the end of each function definition instead of the ;.
Am I missing a semicolon somewhere?
As has been pointed out in the comments, ; is not a statement terminator like in many other (Algol-inspired) languages, but a sequence operator. It takes two values, throws away the first (but warns if it is not unit) and returns the second. a; b is therefore roughly equivalent to let _ = a in b.
You say you would have expected the error to say something like ';' is missing the second operand., but the thing is: it doesn't. Not until it reaches the end of the file (at which point the error message certainly could have been more intelligent, but probably not very accurate anyway).
What follows each ; in your code looks like a perfectly valid expression that might yield a value. For example, if let rec factorial n = ...; had been let rec factorial n = ... in 2 The value of the expression would have been 2. The problem here, from the compiler's point of view, is that it runs out of file before the expression is finished.
As you've also found out, ;; actually is a statement terminator. Or perhaps a toplevel definition terminator is a better term (I don't know if it even has an official name). It's used in the REPL to terminate input, but isn't needed in normal OCaml code unless you mix toplevel definitions and expressions, which you never should.
;; can still be useful for beginners as a "bulkhead", however. If you put just one ;; in place of a ; in the middle of your file, you'll find the compiler now points the error location there. That's because ;; terminates the definition without the preceding expression being complete. So you now know there's an error before that. (Actually in the preceding expression, but since your entire file is one single expression, "before that" is really the best we can do).

weird operator precedence and assignment behavior in borland turboC++

I have to use borland TurboC++ for C programming in my college.
They say our examination board recommends it. I have to use it..
The problem is that they gave this operator precedence related question:
int a=10,b=20,result;
result1 = ++a + b-- - a++ * b++ + a * ++b;
printf("result=%d",);
printf("\n a=%d",a);
printf("\n b=%d",b);
Other compilers like gcc can't perform this operation. But turbo C can and gives us:
result=32
a=12
b=21
I made mistake in my test. My teacher tried to explain what's going on. But I am not convinced. Is it some kind of weird behavior of turbo C or in older days it used to be totally fine with all compilers. If so, what are the steps to understand what is going on and how to understand.
To solve these kind of problem, turbo-c do it in manner as follows :
1) Consider the initial value of variables used.
a=10
b=20
2) Count all the pre-increment and decrements for each variable and store all post on stack separate for each variable.
for variable a
pre increment = 1 therefore change the value of a to 11
post = 1 stored to stack
for variable b
pre increment = 1 therefore change the value of b to 21
post = 2 stored to stack
3) Now replace all the pre and post with the current value of a and b
result = 11 + 21 - 11 * 21 + 11 * 21 ;
result = 11 + 21;
result = 32;
4) lastly pop the stack and perform the operation on the variable.
a = 12
b = 21
This the only way to solve this problem. You can check the procedure with any question of same kind. The result will came out same. g++ fails to solve because it probably cannot resolve the variable in the same way thus the precedence error came in picture. It might probably fail with ++ + and -- - because it cannot understand the increment or decrements operator and forms ambiguous trees.

how do to Xb calculation in R2OpenBUGS, when p is not known

I want to calculate x1b1+x2b2+......+xpbp. However, p is not known, I cannot write it down in advance. So I want to do the following. But in BUGS it says multiple definitions error.
betax <- 0
for(k in 1:p){
betax <- betax + beta[k]*x[i,k]
}
Is there any ways to get it done in bugs model?

Strange Metapost parenthesis bug

When I compile the following Metapost file:
beginfig(1);
def f(expr n) =
if n=0: 0
else: 1
fi;
enddef;
show f(0)+1;
endfig;
end
I expect to get the output 1 (since f(0) is equal to 0, f(0)+1 should be 1!). However, Metapost complains about an Isolated expression.
When I put the expression in parentheses: show (f(0)+1), things get even stranger. The error message becomes : Missing ')' has been inserted. (The first quote should be a backquote, but I couldn't figure out how to escape it). Where on earth was there a mismatched parenthesis??
Thanks for your help!
The def command just expands a name into its definition, so you get literally:
show if 0=0: 0 else: 1;+1;
The semicolon in the middle is what's wrong, so let us remove it:
beginfig(1);
def f(expr n) =
if n=0: 0
else: 1
fi
enddef;
show f(0)+1;
endfig;
end
This produces the correct expansion:
show if 0=0: 0 else: 1+1;
And outputs 1 as expected.
On a side note, I'd recommend using begingroup...endgroup for heavier macro definitions, and at least parentheses for lighter ones: for example,
def f = 1 + 2 enddef;
show f * 2;
gives 1 + 2 * 2, which is not the same as what is probably expected:
def f = (1 + 2) enddef;
show f * 2;
which gives (1 + 2) * 2.