Reliability function r problema with complex model structure - reliability

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

Related

NodeJS string concatenation unusual behaviour

I am trying to construct this string for printing one message.
"At position #[" + index + "][" + _subIndex + "] TLPHN_DVC_TYP " +
+ _telNum?.TelephoneDeviceType.toString() + " ,allowed " + telephoneDeviceTypeEnum.join(',');
from watch is VsCode:
where index =0;_subIndex =0;telNum.TelephoneDeviceType =Mobile;telephoneEnum=["Mobile","Landline"];
It's returning :
At position #[0][0] TLPHN_DVC_TYP NaN ,allowed Mobile,Landline
Full Code:
if (_telNum?.TelephoneDeviceType && !(telephoneDeviceTypeEnum.indexOf(_telNum.TelephoneDeviceType) > 0)){
console.log( "At position #[" + index + "][" + _subIndex + "] TLPHN_DVC_TYP " +
+ _telNum?.TelephoneDeviceType.toString() + " ,allowed " + telephoneDeviceTypeEnum.join(','));
}
the condition should not satisfy but not sure why it's going inside the if and NaN returning. any suggestion?
It's the two plus signs: "] TLPHN_DVC_TYP " + + _telNum?// ...etc. The second one is parsed as the unary +, or a conversion to number, which obviously fails. Compare:
console.log("foo" + "bar");
console.log("foo" + + "bar");
Added #1:
if (_telNum?.TelephoneDeviceType && !(telephoneDeviceTypeEnum.indexOf(_telNum.TelephoneDeviceType) >= 0)){
console.log( "At position #[" + index + "][" + _subIndex + "] TLPHN_DVC_TYP " +_telNum?.TelephoneDeviceType.toString() + " ,allowed " + telephoneDeviceTypeEnum.join(','));
}

How to set split() start and end delimiter?

[(0,
'0.011*"people" + 0.009*"christian" + 0.008*"god" + 0.008*"law" + '
'0.006*"believe" + 0.005*"question" + 0.005*"man" + 0.005*"life" + '
'0.005*"time" + 0.005*"write"'),
(1,
'0.014*"organization" + 0.013*"group" + 0.012*"image" + 0.010*"university" + '
'0.009*"program" + 0.008*"newsletter" + 0.007*"graphic" + '
'0.007*"information" + 0.007*"file" + 0.006*"box"'),
(2,
'0.015*"write" + 0.015*"organization" + 0.014*"article" + 0.012*"year" + '
'0.008*"university" + 0.007*"team" + 0.007*"time" + 0.006*"game" + '
'0.006*"give" + 0.006*"kid"'),
(3,
'0.049*"space" + 0.009*"year" + 0.008*"publish" + 0.006*"aerospace" + '
'0.006*"news" + 0.006*"technical" + 0.005*"satellite" + 0.005*"activity" + '
'0.005*"membership" + 0.005*"system"')]
How do I set the delimeter for the text file shown in the image? I want it to split into four separate text files. What and how should I give the start and end delimiter in the if() as can be seen in the code?. The text file has four separate parts 0,1,2,3. I am trying to write all the parts into separate text file.
`with open('topics.txt','r') as fo:
op=''
start=0
cntr = 1
for x in fo.read().split("\n"):
if (x==''):
if (start==1):
with open(str(cntr) + '.txt','w') as opf:
opf.write(op)
opf.close()
op=''
cntr+=1
else:
start=1
else:
if (op==''):
op = x
else:
op = op + '\n' + x
fo.close()`
If what you posted above is literally your text file, then this should give you each tuple separately.
I'm just using the regular expressions library. The pattern is just look for a left paren ( and run of anything that isn't a right paren, and then a right paren. Super simple.
import re
foo = """[(0,\n blahblahblah), (1,\n asdfasdf), (2,\n ghhgghiegiegieh)]"""
pat = r'\([^\)]+\)'
matches = re.findall(pat, foo)
['(0,\n blahblahblah)', '(1,\n asdfasdf)', '(2,\n ghhgghiegiegieh)']
If you want to separate out the numbers you can do that easily by spliting and striping out the extra stuff:
[i[1:-1].split(',\n')[1].strip() for i in matches]
#['blahblahblah', 'asdfasdf', 'ghhgghiegiegieh']
Then you can write them to whatever file you like.

Nodejs, asny to sync

I am quite new to NodeJs and need some help regarding flow.
So, I need to change some lib as it does not work for me. I have asny call and then right a way i have sync code. The thing is that sync code starts executing before asny part return data.
asny:
xmlenc.encrypt(message, options509, function(err, result) {
console.log("error:", err)
message = result
return message;
})
sync right after asyn:
xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<" + envelopeKey + ":Envelope " +
xmlnsSoap + " " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
encoding +
this.wsdl.xmlnsInEnvelope + '>' +
((self.soapHeaders || self.security) ?
(
"<" + envelopeKey + ":Header>" +
(self.soapHeaders ? self.soapHeaders.join("\n") : "") +
(self.security && !self.security.postProcess ? self.security.toXML() : "") +
"</" + envelopeKey + ":Header>"
)
:
''
) +
"<" + envelopeKey + ":Body" +
(self.bodyAttributes ? self.bodyAttributes.join(' ') : '') +
(self.security && self.security.postProcess ? ' Id="_0"' : '') +
">" +
genXML() +
"</" + envelopeKey + ":Body>" +
"</" + envelopeKey + ":Envelope>";
How to solve this that the progrem with wait for asyn part to return before moving to sync part.
thank you

Get IP Address, Browser Type MVC 5

I need to get local system ip address and browser agent (firefox,chorme,ie,etc..) in MVC 5. Search google Request.ServerVariables["REMOTE_ADDR"] which is not working in MVC5
For getting IP Address use this code:
public static string GetIPAddress(HttpRequestBase request)
{
string ip;
try
{
ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (!string.IsNullOrEmpty(ip))
{
if (ip.IndexOf(",") > 0)
{
string[] ipRange = ip.Split(',');
int le = ipRange.Length - 1;
ip = ipRange[le];
}
}
else
{
ip = request.UserHostAddress;
}
}
catch { ip = null; }
return ip;
}
https://stackoverflow.com/a/7348761/4568359
================================================================
And for getting browser info:
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string brw_info = "Browser Capabilities\n"
+ "Type = " + browser.Type + "\n"
+ "Name = " + browser.Browser + "\n"
+ "Version = " + browser.Version + "\n"
+ "Major Version = " + browser.MajorVersion + "\n"
+ "Minor Version = " + browser.MinorVersion + "\n"
+ "Platform = " + browser.Platform + "\n"
+ "Is Beta = " + browser.Beta + "\n"
+ "Is Crawler = " + browser.Crawler + "\n"
+ "Is AOL = " + browser.AOL + "\n"
+ "Is Win16 = " + browser.Win16 + "\n"
+ "Is Win32 = " + browser.Win32 + "\n"
+ "Supports Frames = " + browser.Frames + "\n"
+ "Supports Tables = " + browser.Tables + "\n"
+ "Supports Cookies = " + browser.Cookies + "\n"
+ "Supports VBScript = " + browser.VBScript + "\n"
+ "Supports JavaScript = " +
browser.EcmaScriptVersion.ToString() + "\n"
+ "Supports Java Applets = " + browser.JavaApplets + "\n"
+ "Supports ActiveX Controls = " + browser.ActiveXControls
+ "\n"
+ "Supports JavaScript Version = " +
browser["JavaScriptVersion"] + "\n";
https://msdn.microsoft.com/en-us/library/3yekbd5b.aspx
To get client IP Address
var IPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(IPAddress))
{
IPAddress = Request.ServerVariables["REMOTE_ADDR"];
}
To get client user agent.
var userAgent = Request.UserAgent;
You are looking for something like to get Ip address
HttpRequest.UserHostAddress Property
and check out this for browser detection 51Degrees.Mobi Foundation

Javascript: Error in String Concatenation

So I have this javascript function:
function show_courseline (course_index, repeats) {
var s = "";
var count = 0;
while (count < repeats) {
s = s + 'Number: ' + document.getElementById(course_index + count + 'a').innerHTML + '\n' +
'Semester: ' + document.getElementById(course_index + count + 'b').innerHTML + '\n' +
'Year: ' + document.getElementById(course_index + count + 'c').innerHTML + '\n' +
'Title: ' + document.getElementById(course_index + count + 'd').innerHTML + '\n' +
'Units: ' + document.getElementById(course_index + count + 'e').innerHTML + '\n' +
'Description: ' + document.getElementById(course_index + count + 'f').innerHTML + '\n';
++count;
}
alert(s);
}
But I get an error when I run it through an "onclick" input box. It has nothing to do with the document ids not being there, because they are.
Is course_index integer? If it is course_index + count is an integer and I know that ids cannot start with a digit

Resources