Studentized residuals in JSL - sas-jmp

How can I add studentized residuals to an already fitted model I have in the JMP table? I have several tables for which I manually open the particular script and do Save Columns--> Studentized Residuals. Any help will be appreciated. Thank you

Write the model to an object. Like:
obj_model = Fit Model(
Y()
X() etc...
);
Now all functionalities of the model can be executed on the obj_model. So studentized residuals can be called as:
obj_model << Studentized Residuals;
In case you have multiple tables, you may want to consider using a loop to save the studentized columns, using the snippet above as the body of the loop.

Related

Returning multiple values in UDF

I have written an AggregateFactory Vertica UDF which returns a single value
getReturnTypes(si,columnTypes args,columnTypes returnTypes){
returnTypes.addVarbinary(512);
//I want to add second returnType
returnTypes.addFloat("");
}
getProtoType(si,columnTypes args,columnTypes returnTypes){
returnTypes.addVarbinary(512);
//I want to add second returnType
returnTypes.addFloat("");
}
this is not working, how can I return two values from an AggregateFactory UDF?
You cannot. User Defined Aggregate Functions (as explained in the fine manual) return ONE value per group. You might want to write a User Defined Transform Function (maybe a multi-phase Transform Function).

How to apply a function on a base class pointer from a map?

I have a map of base class pointers and I need to apply a class function to the mapped data.
I am dealing with shapes the user will input and then has the opportunity to manipulate them (translate, rotate...). I have functions witch work that manipulate the shapes and the shapes are stored in a map.
I am struggling with how to access and manipulate the mapped shapes.
I have the following code;
polygon * T;
map<string, polygon*> shape_map;
new_shape = Trans + user_input; // adds Tranaslated to the key
cout << "ID " << new_shape << " = " << endl; // ouput the key witch also id's the shape
T = shape_map[user_input]->translate(matrix(Xtrans, Ytrans));
T->printshape();
When I run my code the program stops just before it should print the shape and when I debug it highlights a line in my translate function, but I'm confident that my translate function is fine as I have tested it before.
I think the problem is in how I am calling the functions but I'm not certain.
Any help would be great!
If there is no polygon in the shape dictionary stored under the key that's in user_input, shape[user_input] will return null. Assuming translate is not a virtual function, the program will crash when translate accesses 'this'. If it is virtual, it will crash when trying to call translate.
When the key isn't found, a map will construct a new <T>(), but in your case, T is simply a pointer and the default constructor for a pointer sets it to null.

How to average out value returned by an instance method for collection?

I have a simple method inside a model:
def term_months
((started_at - injected_at) / 1.month).to_i
end
This returns a simple integer.
In my View, I have a collection of this model type and I want to average out the results of each model's term_months value.
If this were a column, I could use something like #terms.average(:term_months), but this isn't the case.
Is there some way to average them out inline?
You 'll have to do it manually with a map:
#terms.map(&:term_months).inject(:+).to_f / #terms.length
What you can do is define that as a class method on Term
def self.average_term_months
scoped.map(&:term_months).inject(:+).to_f / scoped.length
end
and use it as #terms.average_term_months
This method is not for use as a classic class method, but more as a scope. However I do not define it as a scope because (personal taste here) I want scopes to be chainable.
#terms.sum(&:term_months).to_f / #terms.size
if started_at and injected_at are columns in your DB, then below would is possible has a better performance than using Enumerable methods (:sum) as it delegates the averaging to the DB and just returns an integer/float object then term_months would not be required:
Model.average("(started_at - injected_at)/ #{1.month}") #where Model is the name of your ActiveRecord Object
You might consider using the quickstats gem, which is designed to update basic statistics on an observation by observation basis as new observations become available. This can be very useful if the dataset is large and you just want the summary stats without having to retain all of the individual observations. Quickstats uses recurrence relationships Xbar(n+1) <- f(Xbar(1), x_n) and s^2(n+1) <- g(s^2(n), x_n), where Xbar(n) and s^2(n) the average and sample variance, respectively, based on n observations; x_n is the nth observation; and f and g represent the appropriate update functions.

Map attributes over to object using an hash

So I have two model objects who hold similar data yet have different attribute names for them. I'll simplify the list for brevity and clarity. I want to actually make a temporary object with the info, compare the objects, and then update one if some of the data has changed. I'm open to suggestions about how to better accomplish this (please keep in mind that there are a lot more attributes then I'm showing)
Member object has the attributes employeenumber, employeefirstname and employeelastname
Censusitem object has the attributes employee_id, employee_fn, employee_ln
I have a has with the fields mapped over that I thought would simplify this:
maps={
employeenumber: :employee_id,
employeefirstname: :employee_fn,
employeelastname: :employee_ln
}
I thought I could then loop them and assign them somehow, but I'm obviously not even close:
def clean_member(censusitem, maps)
tempmember=Member.new
maps.each do |mname,ciname|
tempmember.i[o]=censusitem.i[1]
end
return tempmember
end
Feel like I'm missing something big, which is very normal for me;-) Any help would be greatly appreciated!
Mark
I believe this should work:
def clean_member(censusitem, maps)
tempmember=Member.new
maps.each do |mname,ciname|
tempmember.send("#{mname}=", censusitem.send(ciname))
end
return tempmember
end

Defining Lua methods as initialization

In the Lua language, I am able to define functions in a table with something such as
table = { myfunction = function(x) return x end }
I wondered if I can created methods this way, instead of having to do it like
function table:mymethod() ... end
I am fairly sure it is possible to add methods this way, but I am unsure of the proper name of this technique, and I cannot find it looking for "lua" and "methods" or such.
My intention is to pass a table to a function such as myfunction({data= stuff, name = returnedName, ?method?init() = stuff}).
Unfortunately I have tried several combinations with the colon method declaration but none of them is valid syntax.
So...anyone here happens to know?
Sure: table:method() is just syntactic sugar for table.method(self), but you have to take care of the self argument. If you do
tab={f=function(x)return x end }
then tab:f(x) won't work, as this actually is tab.f(tab,x) and thus will return tab instead of x.
You might take a look on the lua users wiki on object orientation or PiL chapter 16.

Resources