SPSS error when running for manova - spss

I have been having problems with SPSS. When I try to run a data set it says:
>Error # 12005 in column 14. Text: -4
>A parenthesized value range in the MANOVA procedure contains a lower limit
>(the first value) that is greater than the upper limit (the second value).
>Execution of this command stops.
This is the syntax that I am trying to run:
manova P_Progress, P_ObsComp, P_SocFdBk, P_PsyState
by Group4 (1,2,3,4) Group3 (1,2,3)/
print=cellinfo(means)
homogeneity(all)
error(cor)
signif(multiv,univ,stepdown)/
omean=variables(P_Progress, P_ObsComp, P_SocFdBk, P_PsyState) tables(Group4,
Group3)/plot=normal.
I am working on a two way manova.

I advise to consult the IBM SPSS Statistics Syntax Reference regarding the MANOVA. The syntax of MANOVA should be like this:
MANOVA dependent varlist [BY factor list (min,max)[factor list...]
[WITH covariate list]]
I believe this code should work:
manova P_Progress, P_ObsComp, P_SocFdBk, P_PsyState
by Group4 (1,4) Group3 (1,3)
/print = cellinfo(means)
homogeneity(all)
error(cor)
signif(multiv,univ,stepdown)
/omean = variables(P_Progress, P_ObsComp, P_SocFdBk, P_PsyState)
tables(Group4, Group3)
/plot=normal.

Related

SPSS data restructuring

I need to change my SPSS data restructuring from
this
ID1:reading comprehension 1,reading comprehension 2 reading comprehension 3,
ID2:reading comprehension 1,reading comprehension 2 reading comprehension 3,
to
ID1 reading comprehension 1
ID1 reading comprehension 2
ID1 reading comprehension 3
this is the syntax I have tried:
SORT CASES BY ID PunkteT1 PunkteT2 PunkteT3 MW1 MW2 MW3 IMW1 IMW2 IMW3 Vorwissen_T1 Vorwissen_T2
Vorwissen_T3 Interesse_T1 Interesse_T2 Interesse_T3 UMW1 UMW2 UMW3.
CASESTOVARS
/ID=ID
/INDEX=PunkteT1 PunkteT2 PunkteT3 MW1 MW2 MW3 IMW1 IMW2 IMW3 Vorwissen_T1 Vorwissen_T2
Vorwissen_T3 Interesse_T1 Interesse_T2 Interesse_T3 UMW1 UMW2 UMW3
/GROUPBY=VARIABLE.
It doesn't work out because of this warnings:
In case 2, an invalid index value was determined. String index values
can not be empty. Numeric index values must not be negative integers.
The execution of this command has been stopped.
I already tried to solve this but without any success.
Do you have any ideas?
Thanks,
Kathrin
What you have right now are extra variables that you want to turn into cases, so the kind of restructure you need, as #andyW says, is varstocases and not casestovars.
The command will take each set of three variables and turn them into one variable over three cases instead:
varstocases
/make ReadComp FROM ReadComp1 ReadComp2 ReadComp3
/make PunkteT from PunkteT1 PunkteT2 PunkteT3
/make MW from MW1 MW2 MW3
/make IMW from IMW1 IMW2 IMW3
/make Vorwissen_T from Vorwissen_T1 Vorwissen_T2 Vorwissen_T3
/make Interesse_T from Interesse_T1 Interesse_T2 Interesse_T3
/INDEX=OrigVarOrder.

What is the literal expression of NaN in Neo4j Cypher?

How do I express NaN as a literal in a Cypher query?
Situation
I have a NaN value in a database:
match (a) with max(a.CONCENTRATION) as m return m
will return
m
---
NaN
Cypher reference in Neo4j mentioned that this is possible as the result of special value being stored:
The special value java.lang.Double.NaN is regarded as being larger than all other numbers.
What I tried
However, now that it's in there, I don't know how to match them in search, because you get the following error
input
match (a) where a.CONCENTRATION = NaN return a limit 10
error
Variable `NaN` not defined (line 1, column 35 (offset: 34))
Other references
Cypher reference in Neo4j doesn't mention NaN literal, unless I missed it.
I've googled 'Cypher NaN' but the closest thing I got is how to add inf/NaN, which wasn't directly addressed (How to add infinity, NaN, or null values to a double[] property on a node in Cypher/Neo4j).
[UPDATE 2]
Neo4j 5.0 introduced:
the float literals Inf, Infinity, and NaN.
the isNaN() function for determining whether the specified value is NaN.
[ORIGINAL]
There is no way to specify the literal, but this should work:
MATCH (a)
WHERE TOFLOAT(a.CONCENTRATION) <> a.CONCENTRATION
RETURN a
LIMIT 10;
TOFLOAT() will return NULL if the argument cannot be converted (as needed) to a number. But, even if the argument can be converted, the result would not equal the argument unless it was numeric to begin with.
[UPDATE 1]
#chaserino's nice new answer prompted me to do a little more experimentation.
Although there is still no literal for NaN, Infinity, and -Infinity, I determined that Cypher can generate those values in neo4j version 3.4.0+ (I did not test earlier versions). You can then use those values for comparison purposes.
For example, this query shows how to generate those values:
RETURN 0.0/0.0, 1.0/0.0, -1.0/0.0
And here is the result:
╒═════════╤═════════╤══════════╕
│"0.0/0.0"│"1.0/0.0"│"-1.0/0.0"│
╞═════════╪═════════╪══════════╡
│NaN │Infinity │-Infinity │
└─────────┴─────────┴──────────┘
NOTE: For Infinity, you can actually use any positive numerator, and for -Infinity, you can use any negative numerator.
This works in Neo4j 3.5:
MATCH (a)
WHERE TOSTRING(a.CONCENTRATION) = 'NaN'
RETURN a
LIMIT 10;

Prolog solving prefix arithmetic expression with unknown variable

I want to make an arithmetic solver in Prolog that can have +,-,*,^ operations on numbers >= 2. It should also be possible to have a variable x in there. The input should be a prefix expression in a list.
I have made a program that parses an arithmetic expression in prefix format into a syntax tree. So that:
?- parse([+,+,2,9,*,3,x],Tree).
Tree = plus(plus(num(2), num(9)), mul(num(3), var(x))) .
(1) At this stage, I want to extend this program to be able to solve it for a given x value. This should be done by adding another predicate evaluate(Tree, Value, Solution) which given a value for the unknown x, calculates the solution.
Example:
?- parse([*, 2, ^, x, 3],Tree), evaluate(Ast, 2, Solution).
Tree = mul(num(2), pow(var(x), num(3))) ,
Solution = 16.
I'm not sure how to solve this problem due to my lack of Prolog skills, but I need a way of setting the var(x) to num(2) like in this example (because x = 2). Maybe member in Prolog can be used to do this. Then I have to solve it using perhaps is/2
Edit: My attempt to solving it. Getting error: 'Undefined procedure: evaluate/3 However, there are definitions for: evaluate/5'
evaluate(plus(A,B),Value,Sol) --> evaluate(A,AV,Sol), evaluate(B,BV,Sol), Value is AV+BV.
evaluate(mul(A,B),Value,Sol) --> evaluate(A,AV,Sol), evaluate(B,BV,Sol), Value is AV*BV.
evaluate(pow(A,B),Value,Sol) --> evaluate(A,AV,Sol), evaluate(B,BV,Sol), Value is AV^BV.
evaluate(num(Num),Value,Sol) --> number(Num).
evaluate(var(x),Value,Sol) --> number(Value).
(2) I'd also want to be able to express it in postfix form. Having a predicate postfixform(Tree, Postfixlist)
Example:
?- parse([+, *, 2, x, ^, x, 5 ],Tree), postfix(Tree,Postfix).
Tree = plus(mul(num(2), var(x)), pow(var(x), num(5))) ,
Postfix = [2, x, *, x, 5, ^, +].
Any help with (1) and (2) would be highly appreciated!
You don't need to use a grammar for this, as you are doing. You should use normal rules.
This is the pattern you need to follow.
evaluate(plus(A,B),Value,Sol) :-
evaluate(A, Value, A2),
evaluate(B, Value, B2),
Sol is A2+B2.
And
evaluate(num(X),_Value,Sol) :- Sol = X.
evaluate(var(x),Value,Sol) :- Sol = Value.

Syntax for counting cases

I work with SPSS and have difficulty finding/generating a syntax for counting cases.
I have about 120 cases and five variables. I need to know the count /proportion of cases where just one, more than one, or all of the cases have a value of 1 (dichotomous variable). Then I need to compute a new variable that shows the number / proportion of cases which include all of the aforementioned cases (also dichotomous).
For example case number one: var1=1, var2=1, var3=1, var4=0, var5=0 --> newvariable=1.
Case number two: var1=0, var2=0, var3=0, var4=0, var5=0 --> newvariable=1.
And so on...
Can anybody help me with a syntax?
Help would much appreciated!
Here we can use the sum of the variables to determine your conditions. So using a scratch variable that is the sum, we can see if it is equal to 1, more than 1 or 5 in your example.
compute #sum = SUM(var1 to var5).
compute just_one = (#sum = 1).
compute more_one = (#sum > 1).
compute all_one = (#sum = 5).
Similarly, all_one could be computed using the ANY command to evaluate if any zeroes exist, i.e. compute all_one = ANY(0,var1 to var5).. These code snippets assume that var1 to var5 are contiguous in the data frame, if not they just need to be replaced with var1,var2,var3,var4,var5 in all given instances.
You could read up on the logical function ANY in the Command Syntax Reference manual, if you negated a test for ANY with "0", then that is effectively a test for all "1"s. Use of the COUNT command would be another approach.

Constrained Sequence to Index Mapping

I'm puzzling over how to map a set of sequences to consecutive integers.
All the sequences follow this rule:
A_0 = 1
A_n >= 1
A_n <= max(A_0 .. A_n-1) + 1
I'm looking for a solution that will be able to, given such a sequence, compute a integer for doing a lookup into a table and given an index into the table, generate the sequence.
Example: for length 3, there are 5 the valid sequences. A fast function for doing the following map (preferably in both direction) would be a good solution
1,1,1 0
1,1,2 1
1,2,1 2
1,2,2 3
1,2,3 4
The point of the exercise is to get a packed table with a 1-1 mapping between valid sequences and cells.
The size of the set in bounded only by the number of unique sequences possible.
I don't know now what the length of the sequence will be but it will be a small, <12, constant known in advance.
I'll get to this sooner or later, but though I'd throw it out for the community to have "fun" with in the meantime.
these are different valid sequences
1,1,2,3,2,1,4
1,1,2,3,1,2,4
1,2,3,4,5,6,7
1,1,1,1,2,3,2
these are not
1,2,2,4
2,
1,1,2,3,5
Related to this
There is a natural sequence indexing, but no so easy to calculate.
Let look for A_n for n>0, since A_0 = 1.
Indexing is done in 2 steps.
Part 1:
Group sequences by places where A_n = max(A_0 .. A_n-1) + 1. Call these places steps.
On steps are consecutive numbers (2,3,4,5,...).
On non-step places we can put numbers from 1 to number of steps with index less than k.
Each group can be represent as binary string where 1 is step and 0 non-step. E.g. 001001010 means group with 112aa3b4c, a<=2, b<=3, c<=4. Because, groups are indexed with binary number there is natural indexing of groups. From 0 to 2^length - 1. Lets call value of group binary representation group order.
Part 2:
Index sequences inside a group. Since groups define step positions, only numbers on non-step positions are variable, and they are variable in defined ranges. With that it is easy to index sequence of given group inside that group, with lexicographical order of variable places.
It is easy to calculate number of sequences in one group. It is number of form 1^i_1 * 2^i_2 * 3^i_3 * ....
Combining:
This gives a 2 part key: <Steps, Group> this then needs to be mapped to the integers. To do that we have to find how many sequences are in groups that have order less than some value. For that, lets first find how many sequences are in groups of given length. That can be computed passing through all groups and summing number of sequences or similar with recurrence. Let T(l, n) be number of sequences of length l (A_0 is omitted ) where maximal value of first element can be n+1. Than holds:
T(l,n) = n*T(l-1,n) + T(l-1,n+1)
T(1,n) = n
Because l + n <= sequence length + 1 there are ~sequence_length^2/2 T(l,n) values, which can be easily calculated.
Next is to calculate number of sequences in groups of order less or equal than given value. That can be done with summing of T(l,n) values. E.g. number of sequences in groups with order <= 1001010 binary, is equal to
T(7,1) + # for 1000000
2^2 * T(4,2) + # for 001000
2^2 * 3 * T(2,3) # for 010
Optimizations:
This will give a mapping but the direct implementation for combining the key parts is >O(1) at best. On the other hand, the Steps portion of the key is small and by computing the range of Groups for each Steps value, a lookup table can reduce this to O(1).
I'm not 100% sure about upper formula, but it should be something like it.
With these remarks and recurrence it is possible to make functions sequence -> index and index -> sequence. But not so trivial :-)
I think hash with out sorting should be the thing.
As A0 always start with 0, may be I think we can think of the sequence as an number with base 12 and use its base 10 as the key for look up. ( Still not sure about this).
This is a python function which can do the job for you assuming you got these values stored in a file and you pass the lines to the function
def valid_lines(lines):
for line in lines:
line = line.split(",")
if line[0] == 1 and line[-1] and line[-1] <= max(line)+1:
yield line
lines = (line for line in open('/tmp/numbers.txt'))
for valid_line in valid_lines(lines):
print valid_line
Given the sequence, I would sort it, then use the hash of the sorted sequence as the index of the table.

Resources