"show.std" function removes p value formatting in tab_plot (sjPlot) - linear-regression

I have a simple linear model like the one here:
step1 <- lm(data= iris, Sepal.Length ~ Petal.Length + Petal.Width)
I can make a table expressing it using sjPlot:
tab_model(step1)
But adding standardised beta values changes the formatting of the p values:
tab_model(step1,
show.std = T)
Is there a way to stop this from happening?

Daniel provided the solution.
It was a bug in sjPlot.
Using devtools to install sjPlot worked:
install_github("strengejacke/sjPlot")
I had a problem with permissions so I also had to change the install location:
with_libpaths(new = "C:/Program Files/R/R-3.6.0/library", install_github("strengejacke/sjPlot"))
and then changed the default library:
.libPaths("C:/Program Files/R/R-3.6.0/library")

Related

Julia JUMP Gurobi MIP - query and store best objective and bound at runtime

I am using Gurobi through the JuMP package in Julia to solve a mixed-integer program.
I would like to obtain a graph
like this one, where also a solution based on Python is provided (which was also addressed on
Gurobi community form).
However, I have not found working solutions for Julia calling Gurobi through JuMP.
I understand that callback functions have to be used (such as this suggestion or even the main documentation here), but I do not fully understand how they work and what is essential to achieve my goal.
Any help is much appreciated, as well as a possible description of what the callback function is doing at each step.
If it helps, I am using Gurobi (v.9.0.0), JuMP (v0.20.1), MathOptInterface (v0.9.22) and Julia (v.1.3.0).
You need to use the C API. Here is a translation of Eli's answer on the Gurobi forum:
using JuMP, Gurobi
model = direct_model(Gurobi.Optimizer())
N = 30
#variable(model, x[1:N], Bin)
#constraint(model, rand(N)' * x <= 10)
#objective(model, Max, rand(N)' * x)
data = Any[]
start_time = 0.0
function my_callback_function(cb_data, cb_where::Cint)
#show cb_where
if cb_where == GRB_CB_MIP
objbst = Ref{Cdouble}()
GRBcbget(cb_data, cb_where, GRB_CB_MIP_OBJBST, objbst)
objbnd = Ref{Cdouble}()
GRBcbget(cb_data, cb_where, GRB_CB_MIP_OBJBND, objbnd)
push!(data, (time() - start_time, objbst[], objbnd[]))
end
return
end
MOI.set(model, Gurobi.CallbackFunction(), my_callback_function)
start_time = time()
optimize!(model)
open("data.csv", "w") do io
for x in data
println(io, join(x, ", "))
end
end
p.s. please update to Julia 1.6 and JuMP 0.22. I have not tested whether this works on the older version.

How to write a script for Wolfram SystemModeler to run several simulations?

I want to run around 100 simulations with my model changing two parameters f and TLoadand track the changes on the phase currents currentSensor.i[1] etc.
Now I'm stuck with the documentation on the Wolfram website because there is no definite explanation on how to use scripting with the SystemModeler. I found for example this link on the Wolfram site with some code but no explanation in which commandline I should use it.
I downloaded the WolframScript program and tried to open my model with wolframscript -file SMPM_VoltageSource_Inverter.mo but it says ToExpression::sntx: Invalid syntax in or before ... eventhouh my model simulates totally fine and without any errors in the SimulationCenter.
Can someone explain to me:
Is it possible to write scripts ?
If Yes:
How can I simulate my model?
How can I do a parameter sweep of f and TLoad? Is it as described in the link?
Is it possible to export data of currentSensor.i[1] as a csv-file? And how to?
Thank you for any help!
I don't know about wolfram sorry, but for OpenModelica the following works:
// to load Model from file use
// loadFile("fileName.mo");
loadString("
model M
parameter Real a = 1;
Real x;
equation
x = a * sin(time);
end M;
"); getErrorString();
buildModel(M); getErrorString();
for a in {1,2,3,4} loop
str_a := String(a); getErrorString();
system("./M -override a=" + str_a); getErrorString();
// for windows use
//system("M.exe -override a=" + str_a); getErrorString();
system("mv M_res.mat " + "M_" + str_a + ".mat");
end for;
Put this in a file named for example model.mos and call it from terminal or command line, depending on your os, with omc model.mos if you have OpenModelica installed. this should generate a csv.
EDIT: I realized the original just saves the last value of x, you might want the full output. Therefore i changed the .mos-file. Each different result will be saved in a different file, if you want to change it to csv you just have to change the generated xml.

Apply Command to String-type custom fields with YouTrack Rest API

and thanks for looking!
I have an instance of YouTrack with several custom fields, some of which are String-type. I'm implementing a module to create a new issue via the YouTrack REST API's PUT request, and then updating its fields with user-submitted values by applying commands. This works great---most of the time.
I know that I can apply multiple commands to an issue at the same time by concatenating them into the query string, like so:
Type Bug Priority Critical add Fix versions 5.1 tag regression
will result in
Type: Bug
Priority: Critical
Fix versions: 5.1
in their respective fields (as well as adding the regression tag). But, if I try to do the same thing with multiple String-type custom fields, then:
Foo something Example Something else Bar P0001
results in
Foo: something Example Something else Bar P0001
Example:
Bar:
The command only applies to the first field, and the rest of the query string is treated like its String value. I can apply the command individually for each field, but is there an easier way to combine these requests?
Thanks again!
This is an expected result because all string after foo is considered a value of this field, and spaces are also valid symbols for string custom fields.
If you try to apply this command via command window in the UI, you will actually see the same result.
Such a good question.
I encountered the same issue and have spent an unhealthy amount of time in frustration.
Using the command window from the YouTrack UI I noticed it leaves trailing quotations and I was unable to find anything in the documentation which discussed finalizing or identifying the end of a string value. I was also unable to find any mention of setting string field values in the command reference, grammer documentation or examples.
For my solution I am using Python with the requests and urllib modules. - Though I expect you could turn the solution to any language.
The rest API will accept explicit strings in the POST
import requests
import urllib
from collections import OrderedDict
URL = 'http://youtrack.your.address:8000/rest/issue/{issue}/execute?'.format(issue='TEST-1234')
params = OrderedDict({
'State': 'New',
'Priority': 'Critical',
'String Field': '"Message to submit"',
'Other Details': '"Fold the toilet paper to a point when you are finished."'
})
str_cmd = ' '.join(' '.join([k, v]) for k, v in params.items())
command_url = URL + urllib.urlencode({'command':str_cmd})
result = requests.post(command_url)
# The command result:
# http://youtrack.your.address:8000/rest/issue/TEST-1234/execute?command=Priority+Critical+State+New+String+Field+%22Message+to+submit%22+Other+Details+%22Fold+the+toilet+paper+to+a+point+when+you+are+finished.%22
I'm sad to see this one go unanswered for so long. - Hope this helps!
edit:
After continuing my work, I have concluded that sending all the field
updates as a single POST is marginally better for the YouTrack
server, but requires more effort than it's worth to:
1) know all fields in the Issues which are string values
2) pre-process all the string values into string literals
3) If you were to send all your field updates as a single request and just one of them was missing, failed to set, or was an unexpected value, then the entire request will fail and you potentially lose all the other information.
I wish the YouTrack documentation had some mention or discussion of
these considerations.

stuck with my small code in matlab

I have problem with the following code:
.
.
.
a=zeros(1000,ctimes);
a1=zeros(1000,ctimes);
hold all
for i=num1:num2;
colors=Lines(i);
switch phantom
case 1
path=['E:\filename\'];
path1=['E:\filename2\'];
n=['S',num2str(emt),'_',num2str(i),'.m'];
d=load([path,name]);
a(:,i)=complex(d(:,2),d(:,3)));
n1=['S',num2str(emt),'_',num2str(i),'.m'];
d1=load([path1,name1]);
a1(:,i)=complex(d1(:,2),d1(:,3)));
the problem is that a(:,i) can not be defined. while there is no problem or with complex(d1(:,2),d1(:,3))) , can any expert body help me plz?!
thank you ...
Are you sure you are forming your file name correctly? You are doing something to create a variable n, but using a variable name when you form the path. Here are some recommended debugging steps:
1) make sure the file path is formed correctly:
filePath = fullfile(path, name);
disp(filePath);
The fullfile function concatenates elements of a file path & name, and takes care of using the right file path separator (good for portable code, stops you having to remember to add a / or \ to the end of a file path, etc).
2) check that d is loaded correctly:
clear d;
d = load(filePath);
disp(size(d));
3) check the size of the complex quantity you compute before assigning it to a(:,i):
temp = complex(d(:,2), d(:,3));
disp(size(temp));
By the time you have done these things, you should have found your problem (the dimensions of temp should be [1000 1] to match the size of a(:,i), of course).
As an aside, you should avoid using i as a variable name, especially when you are using complex numbers, since its built-in value is sqrt(-1). Thus, c = a + i * b; would create a complex number (a,b) and put it into c - until you change the meaning of i. A simple solution is to use ii. The same is true for j, by the way. It is one of the unfortunate design decisions in Matlab that you can overwrite built in values like that...

Identifying .patch files

Here is the problem. I am writing a piece of software that query bug attachments from a Bug Tracking System. I am able to filter the query by only getting text attachment (plain/text etc) and I want to keep only valid patch files (files that have a similar diff -u output that can be applied as a patch to a source file). So I need a way to specify which attachment is a valid patch. For example:
let say I have this attachment with the following content:
Index: compiler/cpp/src/generate/t_csharp_generator.cc
--- compiler/cpp/src/generate/t_csharp_generator.cc (revision 1033689)
+++ compiler/cpp/src/generate/t_csharp_generator.cc (working copy)
## -456,7 +456,7 ##
t = ((t_typedef*)t)->get_type();
}
if ((*m_iter)->get_value() != NULL) {
- print_const_value(out, "this." + (*m_iter)->get_name(), t, (*m_iter)->get_value(), true, true);
+ print_const_value(out, "this._" + (*m_iter)->get_name(), t, (*m_iter)->get_value(), true, true);
}
}
How can I know this is a valid patch? Is there a regex to match some possible diff -u outputs so I can write something like this in java:
String attachmentContent = .....
if(attachmentContent.matches(regex))...
Thank you in advance,
Elvis
You won't be able to test with a simple Regex, nor a complex by the way, it would require a regular expression engine which is able to interpret the portions between ## as numbers, and define repetition counts from that, I don't know a RE engine which does that.
On the other hand you should not have too much problems finding a library parsing and loading Unix patches (and this is definitely not a compute-intensive task), so simply trying to load the patch would allow you to validate it. e.g. Java diff utils should do that straight forward.