Non-Conformable Arrays when Doing Matrix Multiplication in R
<p>I am trying to implement Kernel Ridge Regression in R.</p>

<p>The formula is:</p>

<pre><code>alpha &lt;- ((lambda.I + K)^(-1)) * y
</code></pre>

<p>Lambda = 0.1. I = identity matrix the same size as K. y is a feature vector that has the same number of rows as K.</p>

<p>So I tried this in R:</p>

<pre><code>I &lt;- diag(nrow(df_matrix)
lambda &lt;- 0.1
alpha &lt;- (lambda * I + df_matrix) ^ (-1) * df_vector
</code></pre>

<p>I get the following error</p>

<pre><code>Error in (0.1 * I + df_matrix)^(-1) * df_vector : non-conformable arrays
</code></pre>

<p>Here's some information on my dataset</p>

<pre><code>&gt; nrow(df_matrix)
[1] 8222
&gt; ncol(df_matrix)
[1] 8222
&gt; nrow(df_vector)
[1] 8222
&gt; nrow(I)
[1] 8222
&gt; ncol(I)
[1] 8222
&gt; class(df_matrix)
[1] "matrix"
&gt; class(df_vector)
[1] "matrix"
</code></pre>