VAR() interact exogenous dummy variables? - regression

I am estimating a VAR model with the VAR()-function. I have to include dummies to control for seasonality. I wondered if it is possible to also include interacted dummies like in a simple linear regression. I tried the following, but it did not work:
Var1 <- VAR(vardata1,p = 3,type = "none",exogen = dummy1:dummy2)

Related

Applying a non linear ARX model in matlab

I estimated parameters of a non- linear arx model with the system identification toolbox in matlab. I was wondering how I can use these results as a function or maybe directly on other inputs. So basically I want to call my arx model function and get the desired output to the given input.
This is the OutputFcn of my estimated model
How would a function of that model look like.
Thank you for your help and pleas keep in mind that I am new to matlab and coding.
Of course I can compare or simulate the model with an iddata object. But thats not useful for my desired application to use the models function with other inputs or to find the deviations to the measured output in dependence to the input.
Best regards

How do I avoid using Global when using a variable in a different function?

I am building a sort of Road Code Quiz type of program that uses the user's inputs across multiple functions.
I established the variable usernote equal to NONE in my main routine, set it as global in my notes() function then updated it to equal something else, and uses it in another function called quizfinish().
The idea was to have a button called a function that take the user's inputs and use it in another Tkinter window, the problem is I constantly use global to allow the program to use variables from another function. I have tried to use return and taking the variable as an argument but have failed due to my lack of coding skills.
Here is a preview of my code:
def notes():
global usernote
usernote = str(ent_notes.get("1.0", "end-1c"))
lbl_notesavestatus.config(text = "Saved!")
def quizfinish():
quizending = Tk()
quizending.title("Well done!")
quizending.geometry("410x365")
lbl_endnotes = Label(quizending, text = usernote)
lbl_endnotes.place(x = 10, y = 190)
usernote = NONE
as you can see, I need to use usernote in quizfinish() but can only do (within my understanding) when I set usernote as a global variable, which from my understanding is not a good practice at all. Also both of these functions are not in any classes.
The code works fine currently, but how could I use usernote in another function without setting it as global?
Change this:
usernote = str(ent_notes.get("1.0", "end-1c"))
to:
usernote = str(ent_notes.get())

Indexing the name of a function in a for loop in Julia

I'm trying to write a for loop to generate multiple functions. I would like to iterate on the name of the functions as well but I can't seem to make it work. Here's what I want to do:
for i = 1:n
h_[i](x) = i*x
end
I know this doesn't work but I would like something like that.
Thanks!
As #laborg mentioned, quite often you don't need/want to use metaprogramming. Since you already try to use array indexing syntax (h_[i]) perhaps you should simply create a vector of functions, for example like so:
h_ = [x->i*x for i in 1:n]
Here, x->i*x is an anonymous function - a function that we don't care to give a name. Afterwards you can use actual array indexing to access these different functions and call them.
Demo:
julia> n = 3;
julia> h_ = [x->i*x for i in 1:n];
julia> h_[1](3)
3
julia> h_[2](3)
6
julia> h_[3](3)
9
No metaprogramming involved.
(On a side note, in this particular example a single function h(x;i) = i*x with a keyword argument i would probably the best choice. But I assume this is a simplified example.)
You have to evaluate the name of your function:
for i = 1:n
f = Symbol(:h_,i)
#eval $f(x) = $i*x
end
More on this:
https://docs.julialang.org/en/v1/manual/metaprogramming/
As a general note on meta programming in Julia: It really helps to think twice if meta programming is the best solution, especially as Julia offers a lot of other cool features, e.g. multiple dispatch.

Hyperbolic functions Sinh, Cosh, Tanh in Action Script 3 (AS3)

I have been implementing a calculator in Action Script 3 and I found Math classes for sin, cos, tan, asin, acos, atan but I do not find any way to implement sinh, cosh, tanh, asinh, acosh, atanh in Action Script 3.
Do I need to write the code on the basis of raw formulas or is there any AS libraries available which do the work. I am not very good in math so do not want to write it using formulas. Also using formula may result in imprecise result.
Please suggest a way to figure it out for both the cases.
What formulas did you intend to use? With the means at hand you can easily define
cosh(x) = 0.5*(exp(x)+exp(-x))
sinh(x) = 0.5*(exp(x)-exp(-x))
tanh(x) = 1-2/(1+exp(2*x)) = (exp(2*x)-1)/(exp(2*x)+1)
acosh(x) = log(x+sqrt(x*x-1))
asinh(x) = log(x+sqrt(x*x+1))
atanh(x) = 0.5*log(2/(1-x)-1) = 0.5*(log(1+x)-log(1-x))

Is there a function head in mathematica that can be used to define an input type?

I am defining a function that takes as input a function and I want to specify it in the input type i.e. Operat[_?FunctionQ]:=...
But there is no functionQ as of yet in mathematica. How do I get aroud this except not specifying any type at all.
Any ideas?
Oh!
This: Test if an expression is a Function?
may be the answer i am looking for. I am reading further
Is the solution proposed there robust?, i.e.:
FunctionQ[_Function | _InterpolatingFunction | _CompiledFunction] = True;
FunctionQ[f_Symbol] := Or[
DownValues[f] =!= {},
MemberQ[ Attributes[f], NumericFunction ]]
FunctionQ[_] = False;
The exhibited definition has great utility. The question is: what exactly constitutes a function in Mathematica? Pure functions and the like are easily to classify as functions, but what about definitions that involve pattern-matching? Consider:
h[g[x_]] ^:= x + 1
Is h to be considered a function? If so, it will be hard to identify as it will entail examining the up-values of every symbol in the system to make that determination. Is g a function? It has an up-value, but g[x] is an inert expression.
What about head composition:
f[x_][y_][z_] := x + y + z
Is f a function? How about f[1] or f[1][2]?
And then there are the various capabilities like JLink and NETLink:
Needs["JLink`"]
obj = JavaNew["java.util.Date"]
obj#toString[]
Is obj#toString a function?
I hate to bring up these problems without offering solutions -- but I want to emphasize that the question as to what constitutes a function in the Mathematica context is a tricky one. It is tricky from both the theoretical and practical standpoints.
I think that the answer to whether the exhibited function test is complete really depends upon the types of expressions that you will be feeding it in your specific application.