Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5818 > unrolled thread

Large control loops

Started byArthur <shukrri@gmail.com>
First post2011-10-23 10:32 +0000
Last post2011-10-26 21:44 +0000
Articles 4 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Large control loops Arthur <shukrri@gmail.com> - 2011-10-23 10:32 +0000
    Re: Large control loops Ray Koopman <koopman@sfu.ca> - 2011-10-24 09:22 +0000
      Re: Large control loops Arthur <shukrri@gmail.com> - 2011-10-25 10:24 +0000
        Re: Large control loops Ray Koopman <koopman@sfu.ca> - 2011-10-26 21:44 +0000

#5818 — Large control loops

FromArthur <shukrri@gmail.com>
Date2011-10-23 10:32 +0000
SubjectLarge control loops
Message-ID<j80qff$ael$1@smc.vnet.net>
Hi guys,

I am trying to do the following (simplified somewhat)

Create matrix A (250x2500 or so)
Run 2500 regressions (each column vs. a common vector) and collect
residuals
Use the residuals to estimate the parameters to 2500 stochastic
processes
Create a list with the top 20 said parameters
Multiply the result by matrix A
Collect results

I can do all of this once, but I need to do all of it approximately
1000 times with slightly different initial matrices. What do you
suggest the best way to go about it would be? If possible I would like
to not have to resort to a secondary language (C/C++, etc.)

[toc] | [next] | [standalone]


#5845

FromRay Koopman <koopman@sfu.ca>
Date2011-10-24 09:22 +0000
Message-ID<j83aon$k7c$1@smc.vnet.net>
In reply to#5818
On Oct 23, 3:32 am, Arthur <shuk...@gmail.com> wrote:
> Hi guys,
>
> I am trying to do the following (simplified somewhat)
>
> Create matrix A (250x2500 or so)
> Run 2500 regressions (each column vs. a common vector) and collect
> residuals
> Use the residuals to estimate the parameters to 2500 stochastic
> processes
> Create a list with the top 20 said parameters
> Multiply the result by matrix A
> Collect results
>
> I can do all of this once, but I need to do all of it approximately
> 1000 times with slightly different initial matrices. What do you
> suggest the best way to go about it would be? If possible I would
> like to not have to resort to a secondary language (C/C++, etc.)

You haven't said what the elements of A and the common vector are.
Are they all numeric? If so then make sure they're packed arrays.

Also, you haven't said which direction the regressions are going.
Is the common vector the predictor or the response?

What kind of regressions? Ordinary least-squares linear, with an
intercept? Or something more complicated?

And how are you estimating the stochastic process parameters?
Is this step likely to take most of the time?

All I can suggest now is that things will probably go faster if
you transpose A so that you work with rows instead of columns.

[toc] | [prev] | [next] | [standalone]


#5856

FromArthur <shukrri@gmail.com>
Date2011-10-25 10:24 +0000
Message-ID<j862ol$5tl$1@smc.vnet.net>
In reply to#5845
Hi,

The vector in the first column is the common vector. It is the
independent variable in the subsequent regressions - I am regressing
first to find the correlation between it and each of the other
vectors. It's all numbers.

OLS regressions.

I am estimating the parameters through a secondary regression on the
residuals of the first and then some basic algebra. It's an Ornstein-
Uhlenbeck process, I am using the first procedure outlined here
http://www.sitmo.com/article/calibrating-the-ornstein-uhlenbeck-model/

I am not so much worried about the time (although that too is a
concern) but the actual structure. Should it just be a long while
loop?

Thanks,

A.

> You haven't said what the elements of A and the common vector are.
> Are they all numeric? If so then make sure they're packed arrays.
>
> Also, you haven't said which direction the regressions are going.
> Is the common vector the predictor or the response?
>
> What kind of regressions? Ordinary least-squares linear, with an
> intercept? Or something more complicated?
>
> And how are you estimating the stochastic process parameters?
> Is this step likely to take most of the time?
>
> All I can suggest now is that things will probably go faster if
> you transpose A so that you work with rows instead of columns.

[toc] | [prev] | [next] | [standalone]


#5892

FromRay Koopman <koopman@sfu.ca>
Date2011-10-26 21:44 +0000
Message-ID<j89v0b$7n$1@smc.vnet.net>
In reply to#5856
On Oct 25, 3:24 am, Arthur <shuk...@gmail.com> wrote:
> The vector in the first column is the common vector. It is the
> independent variable in the subsequent regressions - I am
> regressing first to find the correlation between it and each of
> the other vectors. It's all numbers.
>
> OLS regressions.
>
> I am estimating the parameters through a secondary regression on
> the residuals of the first and then some basic algebra. It's an
> Ornstein-Uhlenbeck process, I am using the first procedure outlined
> here
> http://www.sitmo.com/article/calibrating-the-ornstein-uhlenbeck-model/
>
> I am not so much worried about the time (although that too is a
> concern) but the actual structure. Should it just be a long while
> loop?

par[r] expects r to be a vector of residuals. It uses van den Berg's
first procedure and returns {a,b,sd,lambda,mu,sigma}. Since the
residuals sum to zero, the formulas simplify a little.

par[r_] := Block[{n = Length@r - 1, delta = 1 (* ?? *),
                  Sx,Sy, Sxx,Syy, Sxy, a,b,sd},
  {Sx , Sy } = -r[[{-1,1}]];
  {Sxx, Syy} = n(#.#&@Take[r,{2,-2}] + {Sy,Sx}^2) - {Sx,Sy}^2
  Sxy = n Most@r.Rest@r - Sx*Sy;
  {       a = Sxy/Sxx,
          b = (Sy - a*Sx)/n,
         sd = Sqrt[(Syy - a*Sxy)/(n(n-2))],
  (* lambda = *) -Log[a]/delta,
  (*     mu = *) b/(1-a),
  (*  sigma = *) sd*Sqrt[-2 Log[a]/(delta(1-a^2))]} ]

I would get all the residuals simultaneously,
and then map par over them.

{x,y} = {First@#,Last@#}&[Transpose@A - Mean@A];
p = par /@ (y + Transpose[{y.x/-x.x}].{x}])

Those two lines would be followed by a loop that scans p looking for
the best parameters, and all that would be nested within a loop that
puts different values into A. (Note: rows 1,2,... of p correspond to
column 2,3,... of A.)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web