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.
Related
I want to create Calculated metrics expression for same Logical expression for example by Java
if (KPI<=95 & FailedCount!=0) {
STATUS=1;}
else {STATUS=0;}
In Site Scope I wrote this expression
((<<KPI>><=95)&(<<FailedCount>>!=0))
But I do not like the result
When KPI=0 and FailedCount=0;
STATUS=0,
then KPI=100 and FailedCount=0
STATUS='n/a'.
How to reslove this problem?
p.s.
Add question on HP Community too
There's a ternary operator you can use:
(Boolean Expression)? resultIfExpressionIsTrue: resultIfExpressionIsFalse
In your case you could try to use something like:
((<<KPI>><=95)&(<<FailedCount>>!=0))? 1: 0
You may also need to consider if you want the result to be 0 and 1 as integers (as above) or as strings in which case they should be put in between " marks. This is important from the perspective if you'd like to apply arithmetic or string like thresholds to the resulting calculated metric, also if you'd like the result to be seen as numeric or string values in other places, like in OMi or Service Health etc.
I have 2 variables, one for raw p-values and another for adjusted p-values. I need to compute a new variable based on the values of these two variables. What I need to do isn't too complicated, but I have a hard time doing it in SPSS because I can't figure out how I can reference a particular row for an existing variable in SPSS syntax.
The first column lists raw p-values in ascending order. The next column lists adjusted p-values, but these adjusted p-values are still incomplete. I need to compare two adjacent p-values in the adjusted p-values column (e.g., row 1 and 2, row 2 and 3, row 3 and 4, and so forth), and take the p-values whichever is smaller in each of these comparisons and enter those p-values into the following column as values for a new variable.
However, that's not the end of the story. One more condition has to be met. That is, the new p-values have to be in the same order as the raw p-values. However, I cannot ensure this if I start the comparisons from the top row. You can see that (i') is greater than (h') and (g'), and (d') is greater than (c'), (b'), and (a') in the example below (picture).
In order to solve this issue, I would need to start the comparison of the adjusted p-values from the bottom. In addition, I would need to compare the adjusted p-values to the new p-values of one row below. One exception is that I can simply use the value of (a) as the value of (a') since the value of (a) should always be the greatest of all the p-values as a rule. Then, for (b') , I need to compare (b) and (a') and enter whichever is smaller as (b'). For (c'), I need to compare (c) and (b') and enter whichever is smaller as (c'), and so forth. By doing this way, (d') would be 0.911 and (i') would be 0.017.
Sorry for this long post, but I would really appreciate if I can get some help to do this task in SPSS.
Thank you in advance for your help.
Raw p-values | Adjusted p-values (Temporal)| New p-values (Final)
-------------|-----------------------------|---------------------
0.002 | 0.030 (i) | 0.025 (i')
0.003 | 0.025 (h) | 0.017 (h')
0.004 | 0.017 (g) | 0.017 (g')
0.005 | 0.028 (f) | 0.028 (f')
0.023 | 0.068 (e) | 0.068 (e')
0.450 | 1.061 (d) | 1.061 (d')
0.544 | 1.145 (c) | 0.911 (c')
0.850 | 0.911 (b) | 0.911 (b')
0.974 | 0.974 (a) | 0.974 (a')
Another tool that may be convenient is the SHIFT VALUES command. It can move one or more columns of data either forward or backward.
I wonder whether the purpose of this has to do with adjusting p values for multiple testing corrections as with Benjamin-Hochberg FDR or others similar. If that is the case, you might find the STATS PADJUST (Analyze > Descriptives > Calculate adjusted p values) extension command useful. It offers six adjustment methods. You can install it from the Utilities (pre-V24) or Extensions (V24+) menu.
To get you started, here are a few tools that can help you with this task:
The LAG function
you can compare values in this line and the previous one, for example, the following will compare the Pval in each line to the one in the previous one, and put the smaller of the two in the NewPval:
compute NewPVal=min(Pval, lag(Pval)).
If you want to do the same process only start from the bottom, you can easily sort your data in reverse order and do the same.
CREATE + LEAD
if you want to make comparisons to the next line instead of the previous line, you should first create a "lead" variable and then compare to it.
for example, the following syntax will create a new variable that for each line contains the value of Pval in the next line, and then chooses the smaller of the two for the NewPval:
create /LeadPval=LEAD(Pval 1).
compute NewPVal=min(Pval, LeadPval).
Using case numbers
You can use case numbers (line numbers) in calculations and in conditions. For example, the following syntax will let you make different calculations in the first line and the following ones:
if $casenum=1 NewPval=Pval.
if $casenum>1 NewPVal=min(Pval, lag(Pval)).
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;
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.
I have a set S. It contains N subsets (which in turn contain some sub-subsets of various lengths):
1. [[a,b],[c,d],[*]]
2. [[c],[d],[e,f],[*]]
3. [[d,e],[f],[f,*]]
N. ...
I also have a list L of 'unique' elements that are contained in the set S:
a, b, c, d, e, f, *
I need to find all possible combinations between each sub-subset from each subset so, that each resulting combination has exactly one element from the list L, but any number of occurrences of the element [*] (it is a wildcard element).
So, the result of the needed function working with the above mentioned set S should be (not 100% accurate):
- [a,b],[c],[d,e],[f];
- [a,b],[c],[*],[d,e],[f];
- [a,b],[c],[d,e],[f],[*];
- [a,b],[c],[d,e],[f,*],[*];
So, basically I need an algorithm that does the following:
take a sub-subset from the subset 1,
add one more sub-subset from the subset 2 maintaining the list of 'unique' elements acquired so far (the check on the 'unique' list is skipped if the sub-subset contains the * element);
Repeat 2 until N is reached.
In other words, I need to generate all possible 'chains' (it is pairs, if N == 2, and triples if N==3), but each 'chain' should contain exactly one element from the list L except the wildcard element * that can occur many times in each generated chain.
I know how to do this with N == 2 (it is a simple pair generation), but I do not know how to enhance the algorithm to work with arbitrary values for N.
Maybe Stirling numbers of the second kind could help here, but I do not know how to apply them to get the desired result.
Note: The type of data structure to be used here is not important for me.
Note: This question has grown out from my previous similar question.
These are some pointers (not a complete code) that can take you to right direction probably:
I don't think you will need some advanced data structures here (make use of erlang list comprehensions). You must also explore erlang sets and lists module. Since you are dealing with sets and list of sub-sets, they seems like an ideal fit.
Here is how things with list comprehensions will get solved easily for you: [{X,Y} || X <- [[c],[d],[e,f]], Y <- [[a,b],[c,d]]]. Here i am simply generating a list of {X,Y} 2-tuples but for your use case you will have to put real logic here (including your star case)
Further note that with list comprehensions, you can use output of one generator as input of a later generator e.g. [{X,Y} || X1 <- [[c],[d],[e,f]], X <- X1, Y1 <- [[a,b],[c,d]], Y <- Y1].
Also for removing duplicates from a list of things L = ["a", "b", "a"]., you can anytime simply do sets:to_list(sets:from_list(L)).
With above tools you can easily generate all possible chains and also enforce your logic as these chains get generated.