How to use standerror() in depmixS4 - hmmlearn

Summary(fittedmodel) gives me the coefficients of covariance for transition matrics. I am also curious how to get stand error values. it looks like standerror(fittedmodel) can work for that. But I have problem to understand the results. For example, the summary() result of my model and the result of call standardError(fm2a), but I do not understand the results of standardError() function.
code:
mod1 <- depmix(list(rt~1,corr~1),data=speed,transition=~Pacc,nstates=2,
family=list(gaussian(),multinomial("identity")),ntimes=c(168,134,137))
set.seed(3)
fmod1 <- fit(mod1)
standardError(fmod1)

The depmixS4::standardError function returns a data.frame with in the rows the parameters in the same order as when calling e.g. getpars(fmod1). In the first column (par) you will find the parameter estimate, the second column constr you will find a code reflecting whether the estimate is on the bound of the parameter space (bnd), a fixed parameter (fix), or whether the parameter is included in the estimated standard error (inc). The third column (se) provides the estimated standard error for the included parameters. Standard errors for bnd or fix parameters can not be estimated, and hence the value is NA.

Related

How to find most similar to an array in gensim

I know the most_similar method works when entering a previously added string, but how do you reverse search a numpy array of some word?
modelw2v = KeyedVectors.load_word2vec_format('GoogleNews-vectors-negative300.bin.gz',binary=True)
differenceArr = modelw2v["King"] - modelw2v["Queen"]
# This line does not work
modelw2v.most_similar(differenceArr)
The most_similar() method can take vectors as the origin of a search, but you should explicitly specify them as one member of a list provided to the method's positive parameter, so that its logic for handling more simple origins (like a string or list of strings) isn't confused.
Specifically, this should work with your other code:
model23v.most_similar(positive=[differenceArr,])
More generally, you can supply lists of vectors (or word-keys for looking up vectors) to both the positive and negative parameters of this method, and the method will combine them (according to the exact logic you can see in the source code). So for example the prominent word2vec example...
wv('king') - wv('man') + wv('woman') = ?
...can be effected with the most_similar() method without doing your own other vector-arithmetic:
sims = modelw2v.most_similar(positive=['king', 'woman'], negative=['man'])

np.std change ddof within groupby

I was running a manual (I wrote a function) std dev versus numpy's built in.
There was a slight difference in the returned values.
I looked it up and numpy uses ddof=0 by default.
I am trying to figure out how to pass that within a groupby and I am failing.
My groupby is simply this: grouped = houses.groupby('Yr Sold').agg({'SalePrice': np.std})
If I use: np.std(ddof=1) it errors out saying I am missing the required positional argument 'a'.
I looked that up and I see what it is, but it seems to me that 'a' is my 'SalePrice' column.
I have tried a few different ways but every single thing I try results in a syntax error.
Using the groupby syntax above, how do I pass the ddof=1 parameter to adjust numpy's default behavior?
I figured out how to solve my problem, just not by directly using the syntax above.
std_dev_dict = {}
for id, group in houses.groupby('Yr Sold'):
std_dev_dict[id] = np.std(group['SalePrice'], ddof=1)
print(std_dev_dict)

MATLAB selecting items considering the end of their name

I have to extract the onset times for a fMRI experiment. I have a nested output called "ResOut", which contains different matrices. One of these is called "cond", and I need the 4th element of it [1,2,3,4]. But I need to know its onset time just when the items in "pict" matrix (inside ResOut file) have a name that ends with "*v.JPG".
Here's the part of the code that I wrote (but it's not working):
for i=1:length(ResOut);
if ResOut(i).cond(4)==1 && ResOut(i).pict== endsWith(*"v.JPG")
What's wrong? Can you halp me to fix it out?
Thank you in advance,
Adriano
It's generally helpful to start with unfamiliar functions by reading their documentation to understand what inputs they are expecting. Per the documentation for endsWith, it expects two inputs: the input text and the pattern to match. In your example, you are only passing it one (incorrectly formatted) string input, so it's going to error out.
To fix this, call the function properly. For example:
filepath = ["./Some Path/mazeltov.jpg"; "~/Some Path/myfile.jpg"];
test = endsWith(filepath, 'v.jpg')
Returns:
test =
2×1 logical array
1
0
Or, more specifically to your code snippet:
endsWith(ResOut(i).pict, 'v.JPG')
Note that there is an optional third input, 'IgnoreCase', which you can pass as a boolean true/false to control whether or not the matching ignores case.

How to represent a missing xsd:dateTime in RDF?

I have a dataset with data collected from a form that contains various date and value fields. Not all fields are mandatory so blanks are possible and
in many cases expected, like a DeathDate field for a patient who is still alive.
How do I best represent these blanks in the data?
I represent DeathDate using xsd:dateTime. Blanks or empty spaces are not allowed. All of these are flagged as invalid when validating using Jena RIOT:
foo:DeathDate_1
a foo:Deathdate ;
time:inXSDDatetime " "^^xsd:dateTime .
foo:DeathDate_2
a foo:Deathdate ;
time:inXSDDatetime ""^^xsd:dateTime .
foo:DeathDate_3
a foo:Deathdate ;
time:inXSDDatetime "--"^^xsd:dateTime .
I prefer to not omit the triple because I need to know if it was blank on the source versus a conversion error during construction of my RDF.
What is the best way to code these missing values?
You should represent this by just omitting the triple. That's the meaning of a triple that's "not present": it's information that is (currently) unknown.
Alternatively, you can choose to give it the value "unknown"^^xsd:string when there's no death date. The solution in this case is to not datatype it as an xsd:dateTime, but just as a simple string. It doesn't have to be a string of course, you could use any kind of "special" value for this, e.g. a boolean false - just as long as it's a valid literal value that you can distinguish from actual death dates. This will solve the parsing problem, but IMHO if you do this, you are setting yourself up for headaches in processing the data further down the line (because you will need to ask queries over this data, and they will have to take two different types of values into account, plus the possibility that the field is missing).
I prefer to not omit the triple because I need to know if it was blank
on the source versus a conversion error during construction of my RDF.
This sounds like an XY problem. If there are conversion errors, your application should signal that in another way, e.g. by logging an error. You shouldn't try to solve this by "corrupting" your data.

customAttributes function's arguments are set as NAN

I'm trying to work with the customAttributes of Raphael.
But I the problem is with the arguments inside the customAttributes functions are NAN. Please have a look at this http://jsfiddle.net/5CxVW/1/. In console NAN is logged instead of the h,s,b values and undefined is logged for the path1. What I'm expecting is the step values of h,s,b inside the customAttributes function. Also I want to know how to pass any raphael objects to customAttributes function
this seems to work, but I'm not sure why. I've given the path an initial value for hsb, and then animated. Also, I've pulled the path parameter from the customattribute. This was me hitting it with a hammer until it worked, as opposed to surgically dissecting it and working out exactly why it doesn't work.
So on the one hand, horray, it's working. On the other, I've no idea why.
N.
PS. Oh, wait. you're animating the hsb, which means its adding a fractional value to the intial value until the animation is over. If you haven't set the value first, maybe that's why its failing. undefined + .0012 = NaN?

Resources