I am trying to compute measures like the AVE and the CR using the reliability function in the semTools package in r. However I am facing some problems.
This is the model that I am running:
SEMmodel <- '
f1_m =~ x39_22 + x39_24 + x39_25 + x39_26 + x39_27 + x39_28
f2_m =~ x39_9 + x39_16 + x39_17 + x39_18 + x39_19 + x39_21
f3_m =~ x39_5 + x39_6
f4_m =~ x39_31 + x39_32 + x39_33
f5_m =~ x39_10 + x39_13
f1_s =~ x40_4 + x40_5 + x40_6 + x40_7
f2_s =~ x40_1 + x40_2 + x40_3
f1_c =~ x41_21 + x41_23 + x41_24
f2_c =~ x41_1 + x41_2
f3_c =~ x41_14 + x41_16
mo =~ f1_mot + f2_mot + f3_mot + f4_mot + f5_mot
co =~ f1_con + f2_con + f3_con
so =~ f1_soc + f2_soc
mo ~ a*so
co ~ b*so
mo ~ c*co
x38 ~ d*mo
x38 ~ e*so
x37 ~ g*so
x37 ~ i*x38
ind_mo := b*c
ind_38 := a*d + b*c*d
ind_37 := a*d*i + b*c*d*i +e*i
#Covariances
f2_s ~~ f1_s
f4_m ~~ f3_c
f1_m ~~ f2_c
f3_m ~~ so
f1_m ~~ f3_c
f2_m ~~ f3_c
'
fit <- sem(SEMmodel, data=data)
When I get to compute the reliability using
reliability(fit)
I get the following error message
Warning in (apply(ly[[i]], 2, sum)^2) * diag(ve[[i]]) : longer
object length is not a multiple of shorter object length Error in
ly[[i]] %*% ve[[i]] : non-conformable arguments
Can somebody help me in solving this issue?
Thanks in advance
I would like to know if it's actually possible to encode a (binary) sequence with rotations in MILP/MIP.
Given a binary sequence (0,1,1,0,0,0,0,1) and variables x0,x1,x2,x3,x4,x5,x6,x7,
I want to restrict my MILP program such that it takes up one of the following:
(x0,x1,x2,x3,x4,x5,x6,x7) = (0,1,1,0,0,0,0,1) or
(x7,x0,x1,x2,x3,x4,x5,x6) = (0,1,1,0,0,0,0,1) or
...
(x1,x2,x3,x4,x5,x6,x7,x0) = (0,1,1,0,0,0,0,1)
I understand that the rotation can be easily solved by just extending the sequence. But I find myself creating multiple MILP instances, each instance corresponding to exactly one of the cases. If this is infeasible, why?
There are many approaches one could design and it's not really clear in what context you will use it.
Here is a relatively simple one:
A: Introduce n new binary variables: These describe the "root / first zero" decision
s_x0, s_x1, s_x2, s_x3, s_x4, s_x5, s_x6, s_x7
B: Add a simplex-constraint / make those add up to 1: We do want a unique root!
s_x0 + s_x1 + s_x2 + s_x3 + s_x4 + s_x5 + s_x6 + s_x7 = 1
C: Encode all implications for all possible roots which can be chosen
for: s_x0
logic-form | milp-form
s_x0 -> x0 (1-s_x0) + x0 >= 1
s_x0 -> x1 (1-s_x0) + x1 >= 1
s_x0 -> !x2 (1-s_x0) + (1-x2) >= 1
s_x0 -> !x3 (1-s_x0) + (1-x3) >= 1
s_x0 -> !x4 (1-s_x0) + (1-x4) >= 1
s_x0 -> !x5 (1-s_x0) + (1-x5) >= 1
s_x0 -> x6 (1-s_x0) + x6 >= 1
s_x0 -> !x7 (1-s_x0) + (1-x7) >= 1
for: s_x1
s_x1 -> !x0 (1-s_x1) + (1-x0) >= 1
s_x1 -> x1 (1-s_x1) + x1 >= 1
s_x1 -> x2 (1-s_x1) + x2 >= 1
s_x1 -> !x3 (1-s_x1) + (1-x3) >= 1
s_x1 -> !x4 (1-s_x1) + (1-x4) >= 1
s_x1 -> !x5 (1-s_x1) + (1-x5) >= 1
s_x1 -> !x6 (1-s_x1) + (1-x6) >= 1
s_x1 -> x7 (1-s_x1) + x7 >= 1
for ......
This:
Basically exploits the core structure behind the problem:
We need to chose between n different patterns and must enforce the effects
Will get big (at least for human-consumption)
Is rather simple / easy to understand and implement
But also should provide a nice LP-relaxation
This (non-compact) formulation also exploits some strengths of MILP-solvers (e.g. clique-tables)
I'm using Java and generating an Excel file via Apache POI.
The following formula works perfect.
cell4.setCellFormula('(J' + (itemCountSize + 3) + '-H' + (itemCountSize + 3)+ ')')
Now I simply want to divide by the same H value eg. (J50-H50)/H50
cell4.setCellFormula('(J' + (itemCountSize + 3) + '-H' + (itemCountSize + 3)+ ')'+ '/H' + (itemCountSize + 3))
However it still just gives me (J50-H50)...
Any assistance would be appreciated.
Think you need an extra enclosing bracket
Have you tried:
cell4.setCellFormula('((J' + (itemCountSize + 3) + '-H' + (itemCountSize + 3)+ ')'+ '/H' + (itemCountSize + 3) + ')')
Or, simplifying with groovy string templating:
cell4.cellFormula = "((J${itemCountSize+3}-H${itemCountSize+3})/H${itemCountSize+3})" –
What is the cost of the following method. How do you calculate it?
public String joinWords(String[] words) {
String sentence = "";
for (String w : words) {
sentence = sentence + word;
}
return sentence;
}
Assuming that the cost of string concatenation is O(r + s) for two strings of lengths r and s - which historically was the case in Java but may change going forward - the runtime would be O(mn), where n is the total number of characters in the input strings and m is the number of input strings.
To see this, note that if the string lengths are n1, n2, ..., n_m, then the runtime will be
n1 + (n1 + n2) + (n1 + n2 + n3) + ... + (n1 + n2 + ... + n_m)
= m(n_1) + (m - 1)(n_2) + (m - 2)(n-3) + ... + n_m
= m(n_1 + n_2 + ... + n_m) - n_2 - 2n_3 - 3n_4 - ... - (m - 1)n_m
Subject to the constraint that n_1 + ... + n_m = n, this is maximized when n_1 = n and all the other values are 0. In that case, the runtime becomes mn, so the runtime is O(mn).
Apologies, as I'm sure this is a stupid question, but...
Please could anyone explain to me why this:
public class java {
public static void main(String[] args) {
byte zero = 0;
short one = 1;
int three = 3;
long one2 = 1;
float onepointnought = 1.0f;
double onedotnone = 1.0;
char letterh = 'H';
char letterw = 'w';
char letterr = 'r';
char letterd = 'd';
boolean bool = true;
String output = letterh + three + one + one2 + zero + " " + letterw + zero + letterr + one + letterd + " " + (onepointnought+onedotnone) + " " + bool;
System.out.println(output);
} }
Is outputting:
77 w0r1d 2.0 true
I'm expecting it to say "H3ll0 w0r1d 2.0 true"
It's from the interactive online java tutorials over at http://www.learnjavaonline.org/
Thanks!
Neil.
In this sentence
String output = letterh + three + one + one2 + zero + " " + letterw + zero + letterr + one + letterd + " " + (onepointnought+onedotnone) + " " + bool;
the letterh contains 'H' whose ASCII value is 72 & the addition of three + one + one2 + zero is 5 because these are non-string variables, so it is displaying (72 + 5)77 in the result,
you must convert three , one , one2 , zero to sting variable